use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class MessageConverter_from_1_0 method getMessageId.
public static Object getMessageId(final Message_1_0 serverMsg) {
Object messageId = null;
final PropertiesSection propertiesSection = serverMsg.getPropertiesSection();
if (propertiesSection != null) {
final Properties properties = propertiesSection.getValue();
propertiesSection.dispose();
if (properties != null) {
messageId = properties.getMessageId();
}
}
return messageId;
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class SendingLinkEndpoint method receiveFlow.
@Override
public void receiveFlow(final Flow flow) {
UnsignedInteger receiverDeliveryCount = flow.getDeliveryCount();
UnsignedInteger receiverLinkCredit = flow.getLinkCredit();
setDrain(flow.getDrain());
Map<Symbol, Object> properties = flow.getProperties();
if (properties != null) {
final Binary transactionId = (Binary) properties.get(Symbol.valueOf("txn-id"));
if (transactionId != null) {
try {
getSession().getTransaction(transactionId);
} catch (UnknownTransactionException e) {
close(new Error(TransactionError.UNKNOWN_ID, e.getMessage()));
return;
}
}
_transactionId = transactionId;
}
if (receiverDeliveryCount == null) {
setLinkCredit(receiverLinkCredit);
} else {
// 2.6.7 Flow Control : link_credit_snd := delivery_count_rcv + link_credit_rcv - delivery_count_snd
UnsignedInteger limit = receiverDeliveryCount.add(receiverLinkCredit);
if (limit.compareTo(getDeliveryCount().unsignedIntegerValue()) <= 0) {
setLinkCredit(UnsignedInteger.valueOf(0));
} else {
setLinkCredit(limit.subtract(getDeliveryCount().unsignedIntegerValue()));
}
}
// send flow when echo=true or drain=true but link credit is zero
boolean sendFlow = Boolean.TRUE.equals(flow.getEcho()) || (Boolean.TRUE.equals(flow.getDrain()) && getLinkCredit().equals(UnsignedInteger.ZERO));
flowStateChanged();
if (sendFlow) {
sendFlow();
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class ConsumerTarget_1_0Test method createTestMessage.
private Message_1_0 createTestMessage(final Header header, long arrivalTime) {
DeliveryAnnotationsSection deliveryAnnotations = new DeliveryAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
MessageAnnotationsSection messageAnnotations = new MessageAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
ApplicationPropertiesSection applicationProperties = new ApplicationProperties(Collections.emptyMap()).createEncodingRetainingSection();
FooterSection footer = new Footer(Collections.emptyMap()).createEncodingRetainingSection();
MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations, messageAnnotations, new Properties().createEncodingRetainingSection(), applicationProperties, footer, arrivalTime, 0);
final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
when(storedMessage.getContent(eq(0), anyInt())).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
when(storedMessage.getMetaData()).thenReturn(metaData);
return new Message_1_0(storedMessage);
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method doTestDataWithAnnotation.
private void doTestDataWithAnnotation(final byte[] data, final MessageAnnotations messageAnnotations, final String mimeType, final String expectedMimeType) {
final Data value = new Data(new Binary(data));
Message_1_0 sourceMessage;
if (mimeType != null) {
Properties properties = new Properties();
properties.setContentType(Symbol.valueOf(mimeType));
sourceMessage = createTestMessage(properties, messageAnnotations, value.createEncodingRetainingSection());
} else {
sourceMessage = createTestMessage(messageAnnotations, value.createEncodingRetainingSection());
}
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
assertArrayEquals("Unexpected content", data, ((byte[]) convertedMessage.getMessageBody()));
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Properties in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8Test method testDataWithContentTypeAmqpList.
public void testDataWithContentTypeAmqpList() throws Exception {
List<Object> originalMap = Collections.singletonList("testValue");
byte[] bytes = new ListToAmqpListConverter().toMimeContent(originalMap);
final Data value = new Data(new Binary(bytes));
Properties properties = new Properties();
properties.setContentType(Symbol.valueOf("amqp/list"));
Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "amqp/list", convertedMessage.getMessageHeader().getMimeType());
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
assertArrayEquals("Unexpected content", bytes, getBytes(content));
}
Aggregations