Friday, October 14, 2016

RabbitMQ SSL connection Using RabbitMQ Event Adpter in WSO2 CEP- Part 2

stHi all,


This is the continuous blog of this blog. In the previous blog we saw about rabbitMQ broker side configuration. Here we are going to see about specifying CEP side Configuration. RabbitMQ Receiver is an extension for the CEP. So we need to download it and put it into the CEP. Those are given below.

Steps 
  1.  Please visit this link to download RabbitMQ Receiver extension.
  2. Download rabbitmq client jar from this link. 
  3. Place the extension .jar file into the <CEP_HOME>/repository/components/dropins directory which you downloaded in step 1.
  4. Place the rabbitmq client .jar file into the <CEP_HOME>/repository/components/lib directory which you downloaded in step 2.
  5. Start the CEP Server by going to directory <CEP_HOME>/bin in terminal and giving command like sh ./wso2server.sh
  6. Create a Stream in CEP. Refer more here.
  7. Go to Main => Manage => Receiver to open the Available Receivers page and then click Add Event Receiver in the management console. You can get the management console by visiting the https://172.17.0.1:9443/carbon
  8. Select Input Event Adapter Type as rabbitmq.
  9. Then you will get a page like below.


   9. Then you need to specify values for the properties given above. Here I have mentioned important and  mandatory properties' values.

  • Host Name: localhost
  • Host Port: 5671
  • Username: guest
  • Password: guest
  • Queue Name: testsslqueue
  • Exchange Name: testsslexchange
  • SSL Enabled: True
  • SSL Keystore Location: ../client/keycert.p12
  • SSL Keystore Type: PKCS12
  • SSL Keystore Password: MySecretPassword
  • SSL Truststore Location: ../rabbitstore (These are the values we took from the part 1 blog step 5)
  • SSL Truststore Type: JKS
  • SSL Truststore Password: rabbitstore (The password is the one we used when we are key tool command in Step 5)
  • Connection SSL Version: SSL
After specifying above values, select the stream you had add in step 3 and save it. 

Then if there is a message in the queue you mentioned in RabbitMQ broker, you will get it into the CEP. The data from the queue can be used in further in Execution plan for processing and we can publish it.

17 comments:

  1. Hi, I'm trying to create a RabbitMQ Event Receiver on wso2 CEP. I have placed the 2 .jar files in their own folders. But when I go on wso2 CEP console for creating an Event Receiver, I don' t understanding why I have to fill the "Exchange Name" field. I have to receive data from RabbitMQ and I think I mustn' t fill the "Exchanhe Name" field. Can you suggest me how to solve?

    ReplyDelete
    Replies
    1. Here we mentioned exchange name as compulsory field. So you need to give a value to exchange name.

      Delete
    2. Ok, but what name? Can I do a random name?

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I have another problem: when I run the project on Management Console, I have this error: https://dl.dropboxusercontent.com/u/53209900/Exception.txt
      I have made this configuration for receiver: https://dl.dropboxusercontent.com/u/53209900/TestReceiver.xml

      I have developed the project in Eclipse, as you can see here: https://dl.dropboxusercontent.com/u/53209900/Eclipse.png
      and I added the Library Dependency (for maven) to the file TempDiffAnalytics/pom.xml as it is written here: https://www.rabbitmq.com/java-client.html .
      I'm using RabbitMQ 3.6.1 and wso2 CEP 4.2.0 .
      Can you help me, please?

      Delete
    5. Are you creating receiver and publisher as your own?

      Delete
    6. I have create a receiver on wso2 CEP as you have written. I have created a Node Red publisher that sends MQTT data to RabbitMQ. I would send this data to wso2 CEP and so I built a receiver as you wrote. I' m seeing the Expception and I think that the problem could be in org.wso2.carbon.extension.analytics.receiver.rabbitmq-1.0.0.jar file, at file RabbitMQAdapterListener.class . I converted last file in RabbitMQAdapterListener.java, but for now I can' t understand how to solve this problem. Could be that RabbitMQ version (3.6.1) is old?

      Delete
    7. I have done rabbitmq receiver for the version of 3.6.3. I am not sure about version 3.6.1. But now also i tested. If a message send to a rabbitmq queue, the receiver is accepting it.I am not sure about your problem. If you want code base of rabbitMQ receiver, see this link https://github.com/wso2-extensions/analytics-receiver-rabbitmq

      Delete
  2. Hi, Thanks for the blog ! I place the jar files as instructed and configured the Rabbitmq details. I see the exchange and queues are getting created. But the messages in the queue are not getting consumed. A in RMQ console the number of consumers is 0. The System logs dont give any error.


    2016-12-09 14:21:38,119 Event Receiver configuration successfully deployed and in active state: CollectdRMQ
    More
    2016-12-09 14:21:38,118 Producer added to the junction. Stream:collectd:1.0.0
    More
    2016-12-09 14:21:38,118 Connecting receiver CollectdRMQ
    More
    2016-12-09 14:21:38,118 Waiting to connect receiver CollectdRMQ
    More
    2016-12-09 14:21:38,114 Event receiver configuration saved to the filesystem :CollectdRMQ.xml


    Can you please help here.

    RMQ Version 3.6.0
    CEP 4.1.0

    Thanks,

    -Magin

    ReplyDelete
  3. Another observation. I can see that the cep consumer for the queue when there is no message in the queue. but gets disconnected when a message comes to the queue. so cep is trying to processing the message and then it disconnects.

    ReplyDelete
    Replies
    1. Are you doing SSL connection or normal connection? In rabbitmq receiver, it wont disconnect the connection until we shutdown the CEP. So could you please send the log when it disconnects?

      Delete
    2. Thanks for your reply.

      normal connection. below is the log

      TID: [-1234] [] [2016-12-09 22:19:22,814] INFO {org.wso2.carbon.event.receiver.core.EventReceiverDeployer} - Event Receiver configuration successfully deployed and in active state: rmq1
      TID: [-1] [] [2016-12-09 22:19:22,819] INFO {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener} - Successfully connected to RabbitMQ Broker rmq1
      TID: [-1] [] [2016-12-09 22:19:22,839] INFO {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener} - RabbitMQ connection closed for receiver rmq1
      the "connection closed" log entry comes as soon as i put a message in the queue. I don't know how to enable debug mode.

      Delete
    3. Enabled debug.....

      [2016-12-09 23:20:33,206] INFO - Successfully connected to RabbitMQ Broker rmq1 {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener}
      [2016-12-09 23:20:33,209] DEBUG - Channel is not open. Creating a new channel for receiver rmq1 {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener}
      [2016-12-09 23:20:33,218] DEBUG - Bind queue 'hello' to exchange 'collectd' with route key 'hello' {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener}
      [2016-12-09 23:20:33,219] DEBUG - Start consuming queue 'hello' with consumer tag 'amq.ctag-XUByFcnT81b8NbCGawlNfA' for receiverrmq1 {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener}
      [2016-12-09 23:20:33,220] DEBUG - Waiting for next delivery from queue for receiver {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener}
      [2016-12-09 23:20:33,225] INFO - RabbitMQ connection closed for receiver rmq1 {org.wso2.carbon.extension.analytics.receiver.rabbitmq.internal.util.RabbitMQAdapterListener}

      Delete
  4. Can I use the same procedure to build a RabbitMQ Publisher?

    ReplyDelete
    Replies
    1. If you are going to write publisher, you can use same procedure.

      Delete