How To Use OpenLegacy RabbitMQ Consumer

 

This is just a basic example to configure RabbitMQ consumer/producer API.
If you need it for a specific use case please contact your OpenLegacy Customer Success representative.

Prerequisites:

  • SDK based on Mainframe CICS ItemDetails Example.

  • Template RabbitMQ Consumer Project

  • Configure RabbitMQ queues and exchange via RabbitMQ Management Console, for example by following steps:

  1. Go to Queues Tab → Add new queue.
    Name: test.dead-letter.queue

     

  2. Add another new queue.
    Name: test.incoming.queue
    Arguments: test.exchange
    x-dead-letter-routing-key = test.dead-letter

     

  3. Add another new queue.
    Name: test.outgoing.queue

     

  4. Go to Exchange Tab → Add new exchange.
    Name: test.exchange

     

  5. Go to test.exchange.

     

  6. Bind the input and output queues with the exchange.
    Go to Bindings → Add binding from this exchange.
    To queue: test.incoming.queue
    Routing key: test.in

    Add another binding from this exchange.
    To queue: test.outgoing.queue
    Routing key: test.out

     

     

How to Use the OpenLegacy solution for RabbitMQ:

  1. Go to template → project-creation → maven → orchestration-rest-pom.xml.ftl and change version according to your IDE.

     

  2. Create an API project based on the template mentioned above.

  3. Right click on API project folder → Generate APIs from SDK.

  4. Create a service from the SDK's entities. You need to add an additional input field to each new service - this field is the service-key field. We use "method" as the default value, meaning that you need to add a String field named method.

5. Set OL configuration: 

ol: # OpenLegacy Common Properties (OLCommonProperties) # common: cache: enabled: true license: # RabbitMQ Properties (RabbitMqGlobalConsumerProperties) # rabbitmq: global-consumer: consumer: from-queue: test.incomming.queue # for example producer: exchange: test.exchange # for example routing-key: test.out # for example service-key: method

6. Set Spring Boot - RabbitMQ configuration (if needed):

# Spring boot RabbitMQ Properties # spring: rabbitmq: host: <YOUR HOST ADDRESS> port: <port number> username: <USERNAME> password: <PASSWORD> listener: simple: # In order to 'dead-letter' messages. default-requeue-rejected: false #Number of consumers concurrency: 3 #Retry configurations retry: enabled: true max-attempts: 4 initial-interval: 10000

7. Done.

How to Publish messages via the RabbitMQ Management Console:

  1. Go to the relevant RabbitMQ exchange → Publish message.
    Routing Key: test.in
    Payload:

    { "method": "item", "itemNum": "1000" }

It is important to add the service-key field. In the example above it is "method". The value of this field needs to be the service that you want to activate. After publishing the message, it will enter the queue and will then be consumed by the OpenLegacy consumer.