use of org.apache.activemq.command.BrokerId in project activemq-artemis by apache.
the class OpenWireMessageConverter method setAMQMsgBrokerPath.
private static void setAMQMsgBrokerPath(final ActiveMQMessage amqMsg, final String brokerPath) {
String[] brokers = brokerPath.split(",");
BrokerId[] bids = new BrokerId[brokers.length];
for (int i = 0; i < bids.length; i++) {
bids[i] = new BrokerId(brokers[i]);
}
amqMsg.setBrokerPath(bids);
}
use of org.apache.activemq.command.BrokerId in project activemq-artemis by apache.
the class OpenWireMessageConverter method inbound.
public static org.apache.activemq.artemis.api.core.Message inbound(final Message messageSend, final WireFormat marshaller, final CoreMessageObjectPools coreMessageObjectPools) throws Exception {
final CoreMessage coreMessage = new CoreMessage(-1, messageSend.getSize(), coreMessageObjectPools);
final String type = messageSend.getType();
if (type != null) {
coreMessage.putStringProperty(JMS_TYPE_PROPERTY, new SimpleString(type));
}
coreMessage.setDurable(messageSend.isPersistent());
coreMessage.setExpiration(messageSend.getExpiration());
coreMessage.setPriority(messageSend.getPriority());
coreMessage.setTimestamp(messageSend.getTimestamp());
final byte coreType = toCoreType(messageSend.getDataStructureType());
coreMessage.setType(coreType);
final ActiveMQBuffer body = coreMessage.getBodyBuffer();
final ByteSequence contents = messageSend.getContent();
if (contents == null && coreType == org.apache.activemq.artemis.api.core.Message.TEXT_TYPE) {
body.writeNullableString(null);
} else if (contents != null) {
final boolean messageCompressed = messageSend.isCompressed();
if (messageCompressed) {
coreMessage.putBooleanProperty(AMQ_MSG_COMPRESSED, messageCompressed);
}
switch(coreType) {
case org.apache.activemq.artemis.api.core.Message.TEXT_TYPE:
writeTextType(contents, messageCompressed, body);
break;
case org.apache.activemq.artemis.api.core.Message.MAP_TYPE:
writeMapType(contents, messageCompressed, body);
break;
case org.apache.activemq.artemis.api.core.Message.OBJECT_TYPE:
writeObjectType(contents, messageCompressed, body);
break;
case org.apache.activemq.artemis.api.core.Message.STREAM_TYPE:
writeStreamType(contents, messageCompressed, body);
break;
case org.apache.activemq.artemis.api.core.Message.BYTES_TYPE:
writeBytesType(contents, messageCompressed, body);
break;
default:
writeDefaultType(contents, messageCompressed, body);
break;
}
}
// amq specific
coreMessage.putLongProperty(AMQ_MSG_ARRIVAL, messageSend.getArrival());
coreMessage.putLongProperty(AMQ_MSG_BROKER_IN_TIME, messageSend.getBrokerInTime());
final BrokerId[] brokers = messageSend.getBrokerPath();
if (brokers != null) {
putMsgBrokerPath(brokers, coreMessage);
}
final BrokerId[] cluster = messageSend.getCluster();
if (cluster != null) {
putMsgCluster(cluster, coreMessage);
}
coreMessage.putIntProperty(AMQ_MSG_COMMAND_ID, messageSend.getCommandId());
final String corrId = messageSend.getCorrelationId();
if (corrId != null) {
coreMessage.putStringProperty(JMS_CORRELATION_ID_PROPERTY, new SimpleString(corrId));
}
final DataStructure ds = messageSend.getDataStructure();
if (ds != null) {
putMsgDataStructure(ds, marshaller, coreMessage);
}
final String groupId = messageSend.getGroupID();
if (groupId != null) {
coreMessage.putStringProperty(AMQ_MSG_GROUP_ID, coreMessageObjectPools.getGroupIdStringSimpleStringPool().getOrCreate(groupId));
}
coreMessage.putIntProperty(AMQ_MSG_GROUP_SEQUENCE, messageSend.getGroupSequence());
final MessageId messageId = messageSend.getMessageId();
final ByteSequence midBytes = marshaller.marshal(messageId);
midBytes.compact();
coreMessage.putBytesProperty(AMQ_MSG_MESSAGE_ID, midBytes.data);
final ProducerId producerId = messageSend.getProducerId();
if (producerId != null) {
final ByteSequence producerIdBytes = marshaller.marshal(producerId);
producerIdBytes.compact();
coreMessage.putBytesProperty(AMQ_MSG_PRODUCER_ID, producerIdBytes.data);
}
final ByteSequence propBytes = messageSend.getMarshalledProperties();
if (propBytes != null) {
putMsgMarshalledProperties(propBytes, messageSend, coreMessage);
}
final ActiveMQDestination replyTo = messageSend.getReplyTo();
if (replyTo != null) {
putMsgReplyTo(replyTo, marshaller, coreMessage);
}
final String userId = messageSend.getUserID();
if (userId != null) {
coreMessage.putStringProperty(AMQ_MSG_USER_ID, new SimpleString(userId));
}
coreMessage.putBooleanProperty(AMQ_MSG_DROPPABLE, messageSend.isDroppable());
final ActiveMQDestination origDest = messageSend.getOriginalDestination();
if (origDest != null) {
putMsgOriginalDestination(origDest, marshaller, coreMessage);
}
return coreMessage;
}
use of org.apache.activemq.command.BrokerId in project activemq-artemis by apache.
the class BrokerIdTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
BrokerId info = (BrokerId) object;
info.setValue("Value:1");
}
use of org.apache.activemq.command.BrokerId in project activemq-artemis by apache.
the class BrokerIdTest method createObject.
@Override
public Object createObject() throws Exception {
BrokerId info = new BrokerId();
populateObject(info);
return info;
}
use of org.apache.activemq.command.BrokerId in project activemq-artemis by apache.
the class BrokerIdTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
BrokerId info = (BrokerId) object;
info.setValue("Value:1");
}
Aggregations