提问人:Noel93 提问时间:10/3/2023 最后编辑:Justin BertramNoel93 更新时间:10/3/2023 访问量:35
ActiveMQBytesMessage writeBytes 不起作用,消息未发送
ActiveMQBytesMessage writeBytes not working, message not sent
问:
我正在尝试向 ActiveMQ“Classic”5.7.0 发送消息。但是,即使没有错误消息或任何指示出了什么问题,它似乎也没有达到目标。最终,应用程序在等待显然永远不会到来的答案时停止。队列本身不会为每个 Web 管理控制台注册任何传入消息。
该消息的配置如下:
var bytesMessage = session.createBytesMessage();
// Message Header
jmsMessage.clearProperties();
MessageMetadata metadata = getSomeMetadata();
bytesMessage.setStringProperty("Property", metadata.getSomeProperty());
// etc.
// Write Message
bytesMessage.clearBody();
bytesMessage.writeBytes(payload);
log.debug("BytesMessage: {}", bytesMessage);
session
是正确配置的会话
是一个非空字节数组,以这种方式构建:payload
session
var factory = new ActiveMQConnectionFactory();
factory.setBrokerURL(BROKER_URL);
factory.setUserName(USERNAME);
factory.setPassword(PASSWORD);
factory.setClientIDPrefix(APP_NAME);
var connection = factory.createConnection();
connection.start();
var session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
但是,记录的内容如下所示:bytesMessage
ActiveMQBytesMessage {
commandId = 0,
responseRequired = false,
messageId = ID:My-Laptop-13245-1696261289246-1:1:1:1:1,
originalDestination = null,
originalTransactionId = null,
producerId = null,
destination = queue://MY.ACTIVEMQ.QUEUE,
transactionId = null,
expiration = 0,
timestamp = 1696261289705,
arrival = 0,
brokerInTime = 0,
brokerOutTime = 0,
correlationId = null,
replyTo = null,
persistent = true,
type = null,
priority = 4,
groupID = null,
groupSequence = 0,
targetConsumerId = null,
compressed = false,
userID = null,
content = org.apache.activemq.util.ByteSequence@34bb4e23,
marshalledProperties = null,
dataStructure = null,
redeliveryCounter = 0,
size = 0,
properties = {Property=someProperty, ...},
readOnlyProperties = false,
readOnlyBody = false,
droppable = false}
ActiveMQBytesMessage{ bytesOut = null, dataOut = null, dataIn = null }
之后,我尝试发送这样的消息:
Queue destination = session.createQueue(MY_QUEUE);
MessageProducer producer = session.createProducer(destination);
producer.send(destination, bytesMessage);
但消息永远不会到达队列。
所以特别特别,空的对我来说很突出,尽管我不知道这是否是消息没有发送的原因。我做了什么有什么问题吗?我正在使用 .size = 0
ActiveMQBytesMessage{ bytesOut = null, dataOut = null, dataIn = null }
activemq-core:5.7.0
答: 暂无答案
评论