use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.
the class Interaction method attachSourceFilter.
public Interaction attachSourceFilter(final Map<Symbol, Filter> filters) {
Source source = ((Source) _attach.getSource());
source.setFilter(filters);
_attach.setSource(source);
return this;
}
use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.
the class TemporaryDestinationTest method deleteOnCloseWithConnectionClose.
private void deleteOnCloseWithConnectionClose(final Symbol[] targetCapabilities) throws Exception {
String newTemporaryNodeAddress = null;
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Target target = new Target();
target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
target.setDynamic(true);
target.setCapabilities(targetCapabilities);
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
assertThat(attachResponse.getTarget(), is(notNullValue()));
newTemporaryNodeAddress = ((Target) attachResponse.getTarget()).getAddress();
assertThat(newTemporaryNodeAddress, is(notNullValue()));
assertThat(Utils.doesNodeExist(_brokerAddress, newTemporaryNodeAddress), is(true));
interaction.consumeResponse().getLatestResponse(Flow.class);
interaction.doCloseConnection();
}
assertThat(Utils.doesNodeExist(_brokerAddress, newTemporaryNodeAddress), is(false));
}
use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.
the class ManagementTest method drainTemporaryMessageSource.
@Test
@SpecificationTest(section = "2.6.7", description = "The drain flag indicates how the sender SHOULD behave when insufficient messages" + " are available to consume the current link-credit. If set, the sender will" + " (after sending all available messages) advance the delivery-count as much as possible," + " consuming all link-credit, and send the flow state to the receiver.")
public void drainTemporaryMessageSource() throws Exception {
assumeThat(getBrokerAdmin().isManagementSupported(), is(equalTo(true)));
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Target target = new Target();
target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
target.setDynamic(true);
target.setCapabilities(new Symbol[] { Symbol.valueOf("temporary-queue") });
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().openHostname("$management").open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
assertThat(attachResponse.getTarget(), is(notNullValue()));
String newTemporaryNodeAddress = ((Target) attachResponse.getTarget()).getAddress();
assertThat(newTemporaryNodeAddress, is(notNullValue()));
interaction.consumeResponse().getLatestResponse(Flow.class);
final Attach receiverResponse = interaction.attachHandle(UnsignedInteger.ONE).attachRole(Role.RECEIVER).attachSourceAddress(newTemporaryNodeAddress).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(receiverResponse.getSource(), is(instanceOf(Source.class)));
assertThat(((Source) receiverResponse.getSource()).getAddress(), is(equalTo(newTemporaryNodeAddress)));
// 2.6.8 Synchronous Get
// grant credit of 1
interaction.flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow();
// send drain to ensure the sender promptly advances the delivery-count until link-credit is consumed
interaction.flowDrain(true).flow();
Flow flow = interaction.consumeResponse().getLatestResponse(Flow.class);
assertThat(flow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
assertThat(flow.getHandle(), is(equalTo(receiverResponse.getHandle())));
interaction.doCloseConnection();
}
}
use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.
the class AMQPConnection_1_0Impl method sendOpen.
private void sendOpen(final int channelMax, final int maxFrameSize) {
Open open = new Open();
Map<String, Object> props = Collections.emptyMap();
for (ConnectionPropertyEnricher enricher : getPort().getConnectionPropertyEnrichers()) {
props = enricher.addConnectionProperties(this, props);
}
for (Map.Entry<String, Object> entry : props.entrySet()) {
_properties.put(Symbol.valueOf(entry.getKey()), entry.getValue());
}
if (_receivingSessions == null) {
_receivingSessions = new Session_1_0[channelMax + 1];
_sendingSessions = new Session_1_0[channelMax + 1];
}
if (channelMax < _channelMax) {
_channelMax = channelMax;
}
open.setChannelMax(UnsignedShort.valueOf((short) channelMax));
open.setContainerId(getAddressSpace() == null ? UUID.randomUUID().toString() : getAddressSpace().getId().toString());
open.setMaxFrameSize(UnsignedInteger.valueOf(maxFrameSize));
// TODO - should we try to set the hostname based on the connection information?
// open.setHostname();
open.setIdleTimeOut(UnsignedInteger.valueOf(_incomingIdleTimeout));
// set the offered capabilities
if (_offeredCapabilities != null && !_offeredCapabilities.isEmpty()) {
open.setOfferedCapabilities(_offeredCapabilities.toArray(new Symbol[_offeredCapabilities.size()]));
}
if (_remoteDesiredCapabilities != null && _remoteDesiredCapabilities.contains(SoleConnectionConnectionProperties.SOLE_CONNECTION_FOR_CONTAINER)) {
_properties.put(SoleConnectionConnectionProperties.SOLE_CONNECTION_DETECTION_POLICY, SoleConnectionDetectionPolicy.STRONG);
}
open.setProperties(_properties);
sendFrame(CONNECTION_CONTROL_CHANNEL, open);
}
use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_v1_0 method convertMetaData.
@Override
protected MessageMetaData_1_0 convertMetaData(final InternalMessage serverMessage, final EncodingRetainingSection<?> bodySection, final SectionEncoder sectionEncoder) {
Header header = new Header();
header.setDurable(serverMessage.isPersistent());
header.setPriority(UnsignedByte.valueOf(serverMessage.getMessageHeader().getPriority()));
if (serverMessage.getExpiration() != 0l && serverMessage.getArrivalTime() != 0l && serverMessage.getExpiration() >= serverMessage.getArrivalTime()) {
header.setTtl(UnsignedInteger.valueOf(serverMessage.getExpiration() - serverMessage.getArrivalTime()));
}
Properties properties = new Properties();
if (serverMessage.getMessageHeader().getEncoding() != null) {
properties.setContentEncoding(Symbol.valueOf(serverMessage.getMessageHeader().getEncoding()));
}
properties.setCorrelationId(getCorrelationId(serverMessage));
properties.setCreationTime(new Date(serverMessage.getMessageHeader().getTimestamp()));
properties.setMessageId(getMessageId(serverMessage));
Symbol contentType = getContentTypeSymbol(serverMessage.getMessageBody(), serverMessage.getMessageHeader().getMimeType());
properties.setContentType(contentType);
final String userId = serverMessage.getMessageHeader().getUserId();
if (userId != null) {
properties.setUserId(new Binary(userId.getBytes(StandardCharsets.UTF_8)));
}
properties.setReplyTo(serverMessage.getMessageHeader().getReplyTo());
properties.setTo(serverMessage.getTo());
ApplicationProperties applicationProperties = null;
if (!serverMessage.getMessageHeader().getHeaderNames().isEmpty()) {
try {
applicationProperties = new ApplicationProperties(serverMessage.getMessageHeader().getHeaderMap());
} catch (IllegalArgumentException e) {
throw new MessageConversionException("Could not convert message from internal to 1.0" + " because conversion of 'application headers' failed.", e);
}
}
final MessageAnnotations messageAnnotation = createMessageAnnotation(serverMessage.getMessageBody(), serverMessage.getMessageHeader().getMimeType(), bodySection);
return new MessageMetaData_1_0(header.createEncodingRetainingSection(), null, messageAnnotation == null ? null : messageAnnotation.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties == null ? null : applicationProperties.createEncodingRetainingSection(), null, serverMessage.getArrivalTime(), bodySection.getEncodedSize());
}
Aggregations