I have installed Rifidi edge server (open source RFID middleware provide services as osgi bundles) on windows7 and I am trying to develop a java application to connect and communicate with Rifidi edge server. I tried in two ways, firstly from an application external to Rifidi Edge Server and secondly from a OSGi bundle internal to rifidi edge server following link http://wiki.rifidi.net/index.php?title=EdgeServerJMS , I face following problems in both ways.
1) From application external to Rfifid Edge Server
Code of rifidi.xml is
<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
<property name ="brokerURL" value="tcp://localhost:1099"/>
<property name="useAsyncSend" value="true"/>
</bean>
<bean id="topic" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="org.rifidi.edge.external.tags"/>
</bean>
and code of java file is
Connection connection;
ApplicationContext ctx = new ClassPathXmlApplicationContext("rifiditest/rifidi.xml");
ConnectionFactory cf=(ConnectionFactory) ctx.getBean("connectionFactory");
connection = cf.createConnection();
Destination dest1=(Topic) ctx.getBean("topic");
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
In this case code is working fine but giving Exception java.io.EOFException at Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
2) From OSGi bundle internal to Rifidi Edge Server In this case i am using 2 ways to get data using JMS. Firstly by using JMS ConnectionFactory and JMS Topic object and secondly by MessageListener interface
2)(i) By using JMS ConnectionFactory and JMS Topic object
Code of spring xml is
<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
<property name ="brokerURL" value="vm://externalBroker"/>
<property name="useAsyncSend" value="true"/>
</bean>
<bean id="externalMB" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="org.rifidi.edge.external.tags"/>
</bean>
<bean name="hello" class="com.javaworld.rifiditest.Helloworld"
init-method="start" destroy-method="stop" >
<property name="connectionFactory" ref="connectionFactory"/>
<property name="externalMB" ref="externalMB"/>
</bean>
Code of com.javaworld.rifiditest.Helloworld.java is
Connection connection;
connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
Destination dest=externalMB;
MessageConsumer consumer=session.createConsumer(dest);
TextMessage m=(TextMessage) consumer.receive();
System.out.println("---"+m.getText());
connection.close();
It is executing fine but execution hangs at TextMessage m=(TextMessage) consumer.receive(); and not giving any error.
2)(ii) By using MessageListener interface
When using org.rifidi.edge.internal not getting any data and it is giving warning warning, WARN org.apache.activemq.broker.jmx.ManagementContext:357 - Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]
When using org.rifidi.edge.external.tags no error and not getting any data.
Kind help me to solve this PROBLEM