Consuming Advisory Messages - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

ActiveMQ can generate Advisory messages which are put in topics that you can consume. Such messages can help you send alerts in case you detect slow consumers or to build statistics (number of messages/produced per day, etc.) The following Spring DSL example shows you how to read messages from a topic.

The below route starts by reading the topic ActiveMQ.Advisory.Connection. To watch another topic, simply change the name according to the name provided in ActiveMQ Advisory Messages documentation. The parameter mapJmsMessage=false allows for converting the org.apache.activemq.command.ActiveMqMessage object from the JMS queue. Next, the body received is converted into a String for the purposes of this example and a carriage return is added. Finally, the string is added to a file:

<route>
   <from uri=
      "activemq:topic:ActiveMQ.Advisory.Connection?mapJmsMessage=false"/>
   <convertBodyTo type="java.lang.String"/>
   <transform>
      <simple>${in.body}&#13;</simple>
   </transform>
   <to uri="file://data/activemq/?fileExist=Append&amp;   //
      fileName=advisoryConnection-${date:now:yyyyMMdd}.txt" />
</route>

If you consume a message on a queue, you should see the following files under the data/activemq folder:

advisoryConnection-20100312.txt advisoryProducer-20100312.txt

and containing string:

ActiveMQMessage {commandId = 0, responseRequired = false, 
messageId = ID:dell-charles-3258-1268399815140-1:0:0:0:221, 
originalDestination = null, originalTransactionId = null, producerId = ID:
dell-charles-3258-1268399815140-1:0:0:0, destination = 
topic://ActiveMQ.Advisory.Connection, transactionId = null, 
expiration = 0, timestamp = 0, arrival = 0, brokerInTime = 1268403383468,
brokerOutTime = 1268403383468, correlationId = null, replyTo = null, 
persistent = false, type = Advisory, priority = 0, groupID = null,
groupSequence = 0, targetConsumerId = null, compressed = false,
userID = null, content = null, 
marshalledProperties = org.apache.activemq.util.ByteSequence@17e2705,
dataStructure = ConnectionInfo {commandId = 1, responseRequired = true,
connectionId = ID:dell-charles-3258-1268399815140-2:50, 
clientId = ID:dell-charles-3258-1268399815140-14:0, userName = ,
password = *****, brokerPath = null, brokerMasterConnector = false, 
manageable = true, clientMaster = true}, redeliveryCounter = 0, size = 0,
properties = {originBrokerName=master, 
originBrokerId=ID:dell-charles-3258-1268399815140-0:0, 
originBrokerURL=vm://master}, readOnlyProperties = true, 
readOnlyBody = true, droppable = false}