我想發佈文本消息的主題使用apache與activemq駱駝。 以下代碼正常工作,我的客戶端程序能夠將消息轉換爲文本消息。apache駱駝多播轉換文本消息字節消息
<route id="setText">
<from uri="restlet:///test/{testId}?restletMethod=POST" />
<setExchangePattern pattern="InOnly" />
<setBody>
<simple>${header.testId}:${body}</simple>
</setBody>
<to uri="activemq:topic:TestTopic" />
</route>
現在我添加了多播來完成多項操作。多播能夠很好地發揮作用,併成功地向主題發送消息。
<route id="setText">
<from uri="restlet:///test/{testId}?restletMethod=POST" />
<setExchangePattern pattern="InOnly" />
<multicast>
<pipeline>
<!-- some operation -->
</pipeline>
<setBody>
<simple>${header.testId}:${body}</simple>
</setBody>
<to uri="activemq:topic:TestTopic" />
</multicast>
</route>
但是,當向主題發送文本消息時,多播正在將消息轉換爲字節流。我的客戶端程序是無法消耗的消息轉換成TextMessage的bcoz消息是再見格式,下面是對的System.out.println顯示的信息(在我的客戶端程序)
ActiveMQBytesMessage {commandId = 5, responseRequired = true, messageId = ID:R-014-49827-1433324560754-3:1:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:R-014-49827-1433324560754-3:1:1:1, destination = topic://TestTopic, transactionId = null, expiration = 0, timestamp = 1433324582980, arrival = 0, brokerInTime = 1433324582981, brokerOutTime = 1433324583731, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = [email protected], marshalledProperties = [email protected], dataStructure = null, redeliveryCounter = 0, size = 0, properties = {breadcrumbId=ID-R-014-49826-1433324557692-2-1, org_DOT_restlet_DOT_http_DOT_version=1.1, testId=3100026, org_DOT_restlet_DOT_startTime=1433324582521, CamelHttpMethod=PUT, CamelHttpUri=http://localhost:8080/service-bus/test/3100026}, readOnlyProperties = true, readOnlyBody = true, droppable = false} ActiveMQBytesMessage{ bytesOut = null, dataOut = null, dataIn = null }
您能否提供多播的原因是將短信轉換爲字節格式?以及如何發送文本格式的消息?提前致謝。
多播肯定是*不*轉換anthying。你看錯了地方。 – EJP
是的。我明白。它只是將輸入信息傳遞給所有子系統。但是當我用多播進行測試時,我的客戶端程序能夠將消息用作TextMessage。但是這在多播的情況下不會發生。 –