Search in sources :

Example 6 with Symbol

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;
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 7 with Symbol

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));
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open)

Example 8 with Symbol

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();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 9 with Symbol

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);
}
Also used : Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) ConnectionPropertyEnricher(org.apache.qpid.server.plugin.ConnectionPropertyEnricher) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open)

Example 10 with Symbol

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());
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) Date(java.util.Date)

Aggregations

Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)27 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)11 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)7 Map (java.util.Map)6 BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)6 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)6 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)6 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)5 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)5 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)5 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)4 TokenMgrError (org.apache.qpid.server.filter.selector.TokenMgrError)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)4 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)4 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3