use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testHeaderJMSXGroupSeqConversion.
public void testHeaderJMSXGroupSeqConversion() {
int testGroupSequenceNumber = 1;
Map<String, Object> headers = Collections.singletonMap("JMSXGroupSeq", testGroupSequenceNumber);
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setApplicationHeaders(headers);
MessageTransferMessage message = createTestMessage(messageProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertEquals("Unexpected group-sequence", testGroupSequenceNumber, properties.getGroupSequence().intValue());
Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
assertFalse("Unexpected JMSXGroupSeq in application properties", applicationProperties.containsKey("JMSXGroupSeq"));
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testReplyToConversionWhenExchangeAndRoutingKeyAreNull.
public void testReplyToConversionWhenExchangeAndRoutingKeyAreNull() {
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setReplyTo(new ReplyTo(null, null));
MessageTransferMessage message = createTestMessage(messageProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertNull("Unexpected reply-to", properties.getReplyTo());
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class Assembler method assemble.
private void assemble(Frame frame, ByteBuffer segment) {
BBDecoder dec = _decoder.get();
dec.init(segment);
int channel = frame.getChannel();
Method command;
switch(frame.getType()) {
case CONTROL:
int controlType = dec.readUint16();
Method control = Method.create(controlType);
control.read(dec);
emit(channel, control);
break;
case COMMAND:
int commandType = dec.readUint16();
// read in the session header, right now we don't use it
int hdr = dec.readUint16();
command = Method.create(commandType);
command.setSync((0x0001 & hdr) != 0);
command.read(dec);
if (command.hasPayload() && !frame.isLastSegment()) {
setIncompleteCommand(channel, command);
} else {
emit(channel, command);
}
break;
case HEADER:
command = getIncompleteCommand(channel);
List<Struct> structs = null;
DeliveryProperties deliveryProps = null;
MessageProperties messageProps = null;
while (dec.hasRemaining()) {
Struct struct = dec.readStruct32();
if (struct instanceof DeliveryProperties && deliveryProps == null) {
deliveryProps = (DeliveryProperties) struct;
} else if (struct instanceof MessageProperties && messageProps == null) {
messageProps = (MessageProperties) struct;
} else {
if (structs == null) {
structs = new ArrayList<>(2);
}
structs.add(struct);
}
}
command.setHeader(new Header(deliveryProps, messageProps, structs));
if (frame.isLastSegment()) {
setIncompleteCommand(channel, null);
emit(channel, command);
}
break;
case BODY:
command = getIncompleteCommand(channel);
command.setBody(QpidByteBuffer.wrap(segment));
setIncompleteCommand(channel, null);
emit(channel, command);
break;
default:
throw new IllegalStateException("unknown frame type: " + frame.getType());
}
dec.releaseBuffer();
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class LargeMessageBodyTest method messageBodyOverManyFrames.
@Test
public void messageBodyOverManyFrames() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final String subscriberName = "testSubscriber";
byte[] sessionName = "test".getBytes(UTF_8);
ConnectionTune tune = interaction.negotiateProtocol().consumeResponse().consumeResponse(ConnectionStart.class).connection().startOkMechanism(ConnectionInteraction.SASL_MECHANISM_ANONYMOUS).startOk().consumeResponse().getLatestResponse(ConnectionTune.class);
final byte[] messageContent = new byte[tune.getMaxFrameSize() * 2];
IntStream.range(0, messageContent.length).forEach(i -> {
messageContent[i] = (byte) (i & 0xFF);
});
interaction.connection().tuneOk().connection().open().consumeResponse(ConnectionOpenOk.class);
MessageProperties messageProperties = new MessageProperties();
messageProperties.setContentLength(messageContent.length);
interaction.channelId(1).attachSession(sessionName).message().subscribeDestination(subscriberName).subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(0).subscribe().message().flowId(1).flowDestination(subscriberName).flowUnit(MessageCreditUnit.MESSAGE).flowValue(1).flow().message().flowId(2).flowDestination(subscriberName).flowUnit(MessageCreditUnit.BYTE).flowValue(-1).flow().message().transferDestination(BrokerAdmin.TEST_QUEUE_NAME).transferBody(messageContent).transferHeader(null, messageProperties).transferId(3).transfer().session().flushCompleted().flush().consumeResponse().getLatestResponse(SessionCompleted.class);
MessageTransfer transfer = consumeResponse(interaction, MessageTransfer.class, SessionCompleted.class, SessionCommandPoint.class, SessionConfirmed.class);
assertThat(transfer.getBodySize(), is(equalTo(messageContent.length)));
QpidByteBuffer receivedBody = transfer.getBody();
byte[] receivedBytes = new byte[receivedBody.remaining()];
receivedBody.get(receivedBytes);
assertThat(receivedBytes, is(equalTo(messageContent)));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testQpidSubjectTakesPrecedenceOverJmsType.
public void testQpidSubjectTakesPrecedenceOverJmsType() {
final String jmsType = "test-jms-type";
final String qpidSubjectType = "test-qpid-type";
final Map<String, Object> headers = new HashMap<>();
headers.put("x-jms-type", jmsType);
headers.put("qpid.subject", qpidSubjectType);
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setApplicationHeaders(headers);
MessageTransferMessage message = createTestMessage(messageProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertEquals("Unexpected subject", qpidSubjectType, properties.getSubject());
Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
assertTrue("Unexpected entries in application properties", applicationProperties.isEmpty());
}
Aggregations