Below is my .conf file for my JMS queue connection. The queue name in the stanza is the name of the queue that you are going to read from. You will need to get that from your ActiveMQ admin person.
The other thing to note is that I had to write two java classes -- one to implement the context factory, and one as a message handler. You will need to build a jar file containing your classes & dependencies and put it in the jms_ta/bin/lib directory. (Please excuse any typos...I had to retype it as I am on a closed system) I hope this helps
[jms://queue/:nameOfQueueToReadFrom]
browse_frequency=30
browse_queue_only=0
destination_pass=****
destination_user=system
durable=0
index=foo
index_message_header = 0
index_message_properties=0
init_mode=local
local_init_mode_resource_factory_impl = mycompany.jmssplunk.MyResourceFactory
local_init_mode_resource_factory_params=serverURL="tcp://7.123.12.44:61616,userName=system,password=password
message_handler_impl=`mycompany.jmssplunk.MyMessageHandler`
message_selector=type=summary
strip_newlines=1
sourcetype=foo-bar
disable=1
This is the java class for the initial context:
package mycompany.jmssplunk;
import com.splunk.modinput.jms.LocalJMSResourceFactory;
import javax.jms.*;
import org.apache.activemq.ActiveMQConnectionFactory;
public class MyResourceFactory implements LocalJMSResourceFactory {
private String serverURL;
private String userName;
private String password;
@Override
public void setParams(Map<String,String> params) throws Exception {
try {
this.serverURL=params.get("serverURL");
this.userName=params.get("userName");
this.password=params.get("password");
} catch (Throwable e) {
throw new Exception("Error setting parameters for resource factory - " + e.getMessage();
}
}
@Override
public Queue createQueue (String queueName) throws Exeption {
Session session = null;
try {
ConnectionFactory factory = createConnectionFactory();
Connection connection = factory.createConnection(userName, password);
session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(queueName);
return queue;
} catch (Throwable e) {
throw new Exception("Error creating Queueu - " + e.getMessage();
}
}
@Override
public ConnectionFactory createConnectionFactory() throws Exception{
try {
ConnectionFactory factory = new ActiveMQConnectionFactory(serverURL);
return factory;
} catch (Throwable e) {
throw new Exception("Error creating Queueu - " + e.getMessage();
}
}
}
... View more