2

how to configure jms queue(using activemq inside karaf) inside blueprint.xml which present inside karaf deploy folder..

below is my code which shows config for jms connection inside blueprint.xml..

<bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://localhost:61616" />
    <property name="userName" value="karaf" />
    <property name="password" value="karaf" />
</bean>

<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
    <property name="maxConnections" value="8" />
    <property name="connectionFactory" ref="activemqConnectionFactory" />
</bean>

<bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource">
    <property name="transactionManager" ref="transactionManager" />
    <property name="connectionFactory" ref="activemqConnectionFactory" />
    <property name="resourceName" value="activemq.localhost" />
</bean>

<reference id="transactionManager" interface="javax.transaction.TransactionManager" />

<service ref="activemqConnectionFactory" interface="javax.jms.ConnectionFactory">
    <service-properties>
        <entry key="name" value="connectionFactory" />
        <entry key="osgi.jndi.service.name" value="jms/connectionFactory" />
    </service-properties>
</service>

Aman
  • 31
  • 3

1 Answers1

-1

You don't configure a queue in OSGi, like you did in J2EE. You just use the connection factory in your plain Java or to configure the camel-jms component.

Matt Pavlovich
  • 4,087
  • 1
  • 9
  • 17
  • Hi, but how we will get queue object from jndi lookup ?? Can you give me some example that how you are getting queue object on consumer side using jndi lookup.. here is my consumer code- – Aman Mar 31 '16 at 11:51
  • Context context = new InitialContext(); ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("osgi:service/jms/connectionFactory"); connection = connectionFactory.createConnection(); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("Request_Queue"); – Aman Mar 31 '16 at 11:57
  • here i am hard coading the queue name "Request_Queue" but the same i want to pick by using jndi look up..like below Destination queue = (Destination) context.lookup("MyQueue"); – Aman Mar 31 '16 at 11:58
  • You would need to install the Karaf jndi feature so you have a jndi context available. If this is new code, just inject the ConnectionFactory to your class, and bypass using the jndi lookup altogether – Matt Pavlovich Apr 01 '16 at 19:10
  • hi, Sorry, I could not get you. can you please share any link which can sort out my problem...My main problem is i am not able to get Queue object using jndi lookup..like (Destination queue = (Destination) context.lookup("MyQueue")) i am able to get connectionfactory object like below ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("osgi:service/jms/connectionFactory"); but not able to get queue object because its object is not register with jndi.. So now the main point is how to register queue object in jndi which present inside karaf.?? – Aman Apr 05 '16 at 10:18