Code Monkey home page Code Monkey logo

common-messaging-parent's Introduction

License Build Status Codacy Badge Slack Codecov Maven Central Semver

common-messaging-parent

Description

This repository contains the source code for common-contract-enricher, common-testing, and common-rabbitmq.

  • common-contract-enricher helps with the generation of classes from the API Java Shared Data (JSD) files.

  • common-testing is a tiny artifact used as a test dependency to provide small utilities for JUnit testing purposes (such as message file reader function) The testing dependency import should use the scope import:

<scope>import</scope>
  • common-rabbitmq is a library of AMQP-related functions including but not limited to:
    • message aggregator
    • base Spring configuration
    • basic messaging validation checks
    • default retry policy
    • basic error handling

Documentation

You can find additional documentation for Project Symphony at dellemc-symphony.readthedocs.io.

Before you begin

Verify that the following tools are installed:

  • Apache Maven 3.0.5+
  • Java Development Kit (version 8)

Building

Run the following command to build this project:

mvn clean install

Useage

Connecting to Rabbit MQ with SSL

For connecting to Rabbit MQ using SSL the following presequisites are required:-

  • Get the root ca, client certificate and the key from tls-service. (Which inturn gets it form Vault) README (tls-service)
    • Use the tls-service rest api to get the ca and the client certs.
  • Get the amqp username and password from credential-service. (Which inturn gets it form Vault)
  • Create a Java Key Store i.e. jks and import the keys and certs, using the following steps:-
    • Convert the client pem to der file
    openssl x509 -outform der -in <client-cert>.pem -out <client-cert>.der
    • Export pem client key to pkcs12 format
    openssl pkcs12 -export -inkey <client-cert>.pem -in <client-cert>.pem -chain -CAfile <root-ca>.crt -out <pkcs12-file>.p12 -password pass:<pkcs12-password>
    • Create JKS from pkcs12
    keytool -importkeystore -deststorepass <jks-password> -destkeypass <jks-password> -destkeystore <jks-file>.jks -srckeystore <pkcs12-file>.p12 -srcstoretype PKCS12 -srcstorepass <pkcs12-password>
    • Import root ca to jks
    keytool -import -keystore <jks-file>.jks -file <root-ca>.crt -alias cpsd.root.ca -storepass <jks-password> -noprompt
    • Import client cert to jks
    keytool -import -keystore <jks-file>.jks -file <client-cert>.der -alias cpsd.intermideate.ca -storepass <jks-password> -noprompt
  • Pass the jks ,its password and amqp credentials as JVM arguments.
    java -Xms64m -Xmx192m  \
        -cp <your-classpath-1>:<your-classpath-2> \
        -Dcontainer.id=$CONTAINERID \
        -Djavax.net.ssl.trustStore=<jks-file>.jks \
        -Djavax.net.ssl.trustStorePassword=<jks-password> \
        -Dlog4j.configuration=file:<log4j xml file> \
        -DactiveProfile=<profile> <your-main-class> \
        --remote.dell.amqp.rabbitUsername=<amqp-username> \
        --remote.dell.amqp.rabbitPassword=<amqp-password>
  • The place where you create your RabbitMQCachingConnectionFactory bean use RabbitMQTLSFactoryBean from this project to configure SSL using your jks.
    @Bean
    @Qualifier("rabbitConnectionFactory")
        public ConnectionFactory productionCachingConnectionFactory()
        {
            RabbitMQCachingConnectionFactory cachingCF = null;
            com.rabbitmq.client.ConnectionFactory connectionFactory;
            try{
                if (propertiesConfig.isSslEnabled())
                {
                    RabbitMQTLSFactoryBean rabbitMQTLSFactoryBean = new RabbitMQTLSFactoryBean(propertiesConfig);
                    connectionFactory = rabbitMQTLSFactoryBean.getObject();
                }
                else
                {
                    connectionFactory = new com.rabbitmq.client.ConnectionFactory();
                }
                cachingCF = new RabbitMQCachingConnectionFactory(connectionFactory, propertiesConfig);
            }
            catch (Exception e){
                e.printStackTrace();
            }
            return cachingCF;
        }

NOTE : If you want to configure your own SSL connection and don't want to use this project's SSL configuration with specific algorithm use amqp-rabbit project's RabbitConnectionFactoryBean. For example:

    @Bean
    @Qualifier("rabbitConnectionFactory")
        public ConnectionFactory productionCachingConnectionFactory()
        {
            RabbitMQCachingConnectionFactory cachingCF = null;
            com.rabbitmq.client.ConnectionFactory connectionFactory;
            try{
                if (propertiesConfig.isSslEnabled())
                {
                    RabbitConnectionFactoryBean rabbitConnectionFactoryBean = new RabbitConnectionFactoryBean();
                    rabbitConnectionFactoryBean.setUseSSL(<true or false>);
                    rabbitConnectionFactoryBean.setSslAlgorithm(<ssl-version>);
                    rabbitConnectionFactoryBean.setKeyStoreType(<key-store-type jks or pkcs>);
                    rabbitConnectionFactoryBean.setTrustStoreType(<trust-store-type jks or pkcs>);
                    rabbitConnectionFactoryBean.setTrustStoreResource(new FileSystemResource(<path-to-trust-store>));
                    rabbitConnectionFactoryBean.setTrustStorePassphrase(<trust-store-password>);
                    rabbitConnectionFactoryBean.setKeyStoreResource(new FileSystemResource(<path-to-key-store>));
                    rabbitConnectionFactoryBean.setKeyStorePassphrase(<key-store-password>);
                    rabbitConnectionFactoryBean.afterPropertiesSet();
                    
                    //Override createSSLContext() to create and/or perform further modification of the context.
                    //Override setUpSSL() to take complete control over setting up SSL.
                    
                    connectionFactory = rabbitConnectionFactoryBean.getObject();
                }
                else
                {
                    connectionFactory = new com.rabbitmq.client.ConnectionFactory();
                }
                cachingCF = new RabbitMQCachingConnectionFactory(connectionFactory, propertiesConfig);
            }
            catch (Exception e){
                e.printStackTrace();
            }
            return cachingCF;
        }

Connecting to Rabbit MQ without SSL

  • Get amqp username and password from credential-service
  • Pass amqp credentials as JVM arguments.
    java -Xms64m -Xmx192m  \
        -cp <your-classpath-1>:<your-classpath-2> \
        -Dcontainer.id=$CONTAINERID \
        -Dlog4j.configuration=file:<log4j xml file> \
        -DactiveProfile=<profile> <your-main-class> \
        --remote.dell.amqp.rabbitUsername=<amqp-username> \
        --remote.dell.amqp.rabbitPassword=<amqp-password>

Contributing

Project Symphony is a collection of services and libraries housed at GitHub.

Contribute code and make submissions at the relevant GitHub repository level. See our documentation for details on how to contribute.

Community

Reach out to us on the Slack #symphony channel by requesting an invite at {code}Community.

You can also join Google Groups and start a discussion.

common-messaging-parent's People

Contributors

boettj3 avatar chamap1 avatar codacy-badger avatar dellemcgouldc avatar dennec1 avatar fergalmcmvce avatar fogarl1 avatar kalagp avatar karteekch avatar kumara189 avatar matjo01 avatar murilm avatar olearj10 avatar rajeshkumarvarada avatar ramyagopalan-dell avatar robertdubiszdell avatar rousef42 avatar sannab2 avatar sknightvce avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.