<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read messages from Active MQ Topic in Security</title>
    <link>https://community.splunk.com/t5/Security/Read-messages-from-Active-MQ-Topic/m-p/138445#M14568</link>
    <description>&lt;P&gt;Here is an example stanza that works in my ActiveMQ environment :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[jms://topic/dynamicTopics/splunktopic]
durable = 1
host = some-host
index = main
index_message_header = 1
index_message_properties = 1
init_mode = jndi
jms_connection_factory_name = ConnectionFactory
jndi_initialcontext_factory = org.apache.activemq.jndi.ActiveMQInitialContextFactory
jndi_provider_url = tcp://ubuntu-personal:61616
sourcetype = jms
disabled = 1
browse_mode = stats
browse_queue_only = 0
strip_newlines = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Furthermore , do you have any error messages ? Search "index=_internal ExecProcessor error jms.py"&lt;/P&gt;</description>
    <pubDate>Wed, 23 Apr 2014 08:45:25 GMT</pubDate>
    <dc:creator>Damien_Dallimor</dc:creator>
    <dc:date>2014-04-23T08:45:25Z</dc:date>
    <item>
      <title>Read messages from Active MQ Topic</title>
      <link>https://community.splunk.com/t5/Security/Read-messages-from-Active-MQ-Topic/m-p/138444#M14567</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to configure JMS Modular App to read messages from ActiveMQ Topic. MQ runs locally on the machine and there is a java code that uses jndi and pushes messages into topic called MyTopic. MQ is working fine, each time I run the code, message count in Topic increases (verified on ActiveMQ Web Console).&lt;/P&gt;

&lt;P&gt;Problem is that , I am still unable to index the messages in Splunk.&lt;BR /&gt;
Please let me know where I am wrong.&lt;/P&gt;

&lt;P&gt;Configuration on the UI is as below :&lt;/P&gt;

&lt;P&gt;Initialisation Mode : jndi&lt;BR /&gt;
JMS Connection Factory JNDI Name : connectionFactory&lt;BR /&gt;
JNDI Initial Context Factory Name : org.apache.activemq.jndi.ActiveMQInitialContextFactory&lt;BR /&gt;
JNDI Provider URL : tcp://localhost:61616&lt;BR /&gt;
(Also tried with file:/home/user/MQJNDI/)  jndi.properties file is placed at /home/user/MQJNDI/&lt;/P&gt;

&lt;P&gt;Index message property values , Index message property values and Index message property values are checked.&lt;/P&gt;

&lt;P&gt;Sourcetype : mqTopic (manual)&lt;/P&gt;

&lt;P&gt;After saving the changes, I push messages again in the Topic , but nothing gets indexed.&lt;/P&gt;

&lt;P&gt;jndi.properties is as below:&lt;/P&gt;

&lt;H1&gt;START SNIPPET: jndi&lt;/H1&gt;

&lt;P&gt;java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory&lt;/P&gt;

&lt;H1&gt;use the following property to configure the default connector&lt;/H1&gt;

&lt;P&gt;java.naming.provider.url = tcp://localhost:61616&lt;/P&gt;

&lt;H1&gt;use the following property to specify the JNDI name the connection factory&lt;/H1&gt;

&lt;H1&gt;should appear as.&lt;/H1&gt;

&lt;P&gt;connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry&lt;/P&gt;

&lt;H1&gt;register some queues in JNDI using the form&lt;/H1&gt;

&lt;H1&gt;queue.[jndiName] = [physicalName]&lt;/H1&gt;

&lt;P&gt;queue.MyQueue = MyQueue&lt;/P&gt;

&lt;H1&gt;register some topics in JNDI using the form&lt;/H1&gt;

&lt;H1&gt;topic.[jndiName] = [physicalName]&lt;/H1&gt;

&lt;P&gt;topic.MyTopic = MyTopic&lt;/P&gt;

&lt;H1&gt;END SNIPPET: jndi&lt;/H1&gt;

&lt;P&gt;Java code that writes messages to Topic&lt;BR /&gt;
Arguments : MyTopic 100&lt;/P&gt;

&lt;P&gt;package com.humana.splunk.jms;&lt;/P&gt;

&lt;P&gt;import javax.jms.Connection;&lt;BR /&gt;
import javax.jms.ConnectionFactory;&lt;BR /&gt;
import javax.jms.Destination;&lt;BR /&gt;
import javax.jms.JMSException;&lt;BR /&gt;
import javax.jms.MessageProducer;&lt;BR /&gt;
import javax.jms.Session;&lt;BR /&gt;
import javax.jms.TextMessage;&lt;BR /&gt;
import javax.naming.Context;&lt;BR /&gt;
import javax.naming.InitialContext;&lt;BR /&gt;
import javax.naming.NamingException;&lt;/P&gt;

&lt;P&gt;import org.slf4j.Logger;&lt;BR /&gt;
import org.slf4j.LoggerFactory;&lt;/P&gt;

&lt;P&gt;/**&lt;BR /&gt;
 * A simple polymorphic JMS producer which can work with Queues or Topics which&lt;BR /&gt;
 * uses JNDI to lookup the JMS connection factory and destination&lt;BR /&gt;
 * &lt;BR /&gt;
 * &lt;BR /&gt;
 */&lt;BR /&gt;
public final class SimpleProducer {&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;private static final Logger LOG = LoggerFactory.getLogger(SimpleProducer.class);

private SimpleProducer() {
}

/**
 * @param args the destination name to send to and optionally, the number of
 *                messages to send
 */
public static void main(String[] args) {
    Context jndiContext = null;
    ConnectionFactory connectionFactory = null;
    Connection connection = null;
    Session session = null;
    Destination destination = null;
    MessageProducer producer = null;
    String destinationName = null;
    final int numMsgs;

    if ((args.length &amp;lt; 1) || (args.length &amp;gt; 2)) {
        LOG.info("Usage: java SimpleProducer &amp;lt;destination-name&amp;gt; [&amp;lt;number-of-messages&amp;gt;]");
        System.out.println("args : " + args[0]);
        System.exit(1);
    }
    destinationName = args[0];
    LOG.info("Destination name is " + destinationName);
    if (args.length == 2) {
        numMsgs = (new Integer(args[1])).intValue();
    } else {
        numMsgs = 1;
    }

    /*
     * Create a JNDI API InitialContext object
     */
    try {
        jndiContext = new InitialContext();
    } catch (NamingException e) {
       LOG.info("Could not create JNDI API context: " + e.toString());
        System.exit(1);
    }

    /*
     * Look up connection factory and destination.
     */
    try {
        connectionFactory = (ConnectionFactory)jndiContext.lookup("topicConnectionFactory");
        destination = (Destination)jndiContext.lookup(destinationName);
    } catch (NamingException e) {
       LOG.info("JNDI API lookup failed: " + e);
        System.exit(1);
    }

    /*
     * Create connection. Create session from connection; false means
     * session is not transacted. Create sender and text message. Send
     * messages, varying text slightly. Send end-of-messages message.
     * Finally, close connection.
     */
    try {
        connection = connectionFactory.createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        producer = session.createProducer(destination);
        TextMessage message = session.createTextMessage();
        for (int i = 0; i &amp;lt; numMsgs; i++) {
            message.setText("This is message " + (i + 1));
           LOG.info("Sending message: " + message.getText());
            producer.send(message);
        }

        /*
         * Send a non-text control message indicating end of messages.
         */
        producer.send(session.createMessage());
    } catch (JMSException e) {
        LOG.info("Exception occurred: " + e);
    } finally {
        if (connection != null) {
            try {
                connection.close();
            } catch (JMSException e) {
            }
        }
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;Could you please help me identify/resolve the issue.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2014 15:36:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Read-messages-from-Active-MQ-Topic/m-p/138444#M14567</guid>
      <dc:creator>ManishaAgrawal</dc:creator>
      <dc:date>2014-04-22T15:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Read messages from Active MQ Topic</title>
      <link>https://community.splunk.com/t5/Security/Read-messages-from-Active-MQ-Topic/m-p/138445#M14568</link>
      <description>&lt;P&gt;Here is an example stanza that works in my ActiveMQ environment :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[jms://topic/dynamicTopics/splunktopic]
durable = 1
host = some-host
index = main
index_message_header = 1
index_message_properties = 1
init_mode = jndi
jms_connection_factory_name = ConnectionFactory
jndi_initialcontext_factory = org.apache.activemq.jndi.ActiveMQInitialContextFactory
jndi_provider_url = tcp://ubuntu-personal:61616
sourcetype = jms
disabled = 1
browse_mode = stats
browse_queue_only = 0
strip_newlines = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Furthermore , do you have any error messages ? Search "index=_internal ExecProcessor error jms.py"&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2014 08:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Read-messages-from-Active-MQ-Topic/m-p/138445#M14568</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2014-04-23T08:45:25Z</dc:date>
    </item>
  </channel>
</rss>

