我已經安裝Rifidi邊緣服務器(開源RFID中間件提供服務作爲osgi包)在windows7上,我正在嘗試開發一個Java應用程序來連接和通信與Rifidi邊緣服務器。我嘗試了兩種方式,首先是從Rifidi Edge Server外部的應用程序,然後從內部的OSGi包到rifidi邊緣服務器,鏈接如下:http://wiki.rifidi.net/index.php?title=EdgeServerJMS,我遇到以下兩種問題。無法訪問在Rifidi邊緣服務器(RFID中間件)提供的OSGI服務
1)從應用外部Rfifid邊緣服務器
rifidi.xml的代碼是
<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>
和Java文件的代碼是
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);
在這種情況下的代碼工作正常,但給予Exc eption java.io.EOFException at Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
2)從OSGi包內部Rifidi邊緣服務器 在這種情況下,我使用2種方式使用JMS來獲取數據。首先,通過使用JMS連接和JMS主題對象,其次通過MessageListener接口
2)(ⅰ)通過使用JMS連接和JMS主題對象
彈簧XML的代碼是
<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>
代碼com.javaworld.rifiditest.Helloworld.java是
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();
它執行正常但執行掛起在TextMessage m =(TextMessage)consumer.receive();並沒有給出任何錯誤。
2)(ii)使用MessageListener接口
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]
當使用org.rifidi.edge.external.tags沒有錯誤,沒有得到任何數據。
熱心幫助我解決這個問題
「這不是工作「不是一個非常有用的錯誤描述。實際發生了什麼,你期望*發生了什麼,有沒有任何錯誤信息,等等...... –
親愛的尼爾,非常感謝你的回覆。我沒有收到任何錯誤消息。我期望得到POJO提供的Rifidi Edge Server使用 。但在做這個我的Osgi捆綁不讀xml。我正是遵循這些鏈接http://wiki.rifidi.net/index.php?title=Edge_Server_Architecture http://wiki.rifidi.net/index.php?title=EdgeServerJMS訪問rifidi邊緣服務器的服務 –
@NeilBartlett請問如果你仍然沒有得到我的問題。我已經創建&導出我自己的服務在OSGI捆綁和訪問它從另一個OSGI捆綁使用標籤在春天xml,捆綁閱讀xml&我越來越但是當我試圖訪問由Rifidi邊緣服務器導出的服務時,我的包不會讀取xml.For參考這些鏈接http://wiki.rifidi.net/index.php?title=Edge_Server_Architecture& http://wiki.rifidi.net/index.php?title=EdgeServerJMS顯示了我正在嘗試做的事。親切地幫助我解決這個問題。 –