Search in sources :

Example 6 with Accepted

use of com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted in project swiftmq-client by iitsoftware.

the class Producer method recover.

protected void recover(AMQPMap remoteUnsettled) {
    try {
        if (remoteUnsettled != null) {
            Map<AMQPType, AMQPType> map = remoteUnsettled.getValue();
            for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
                Map.Entry entry = (Map.Entry) iter.next();
                final DeliveryTag deliveryTag = new DeliveryTag(((AMQPBinary) entry.getKey()).getValue());
                final AMQPList deliveryState = (AMQPList) entry.getValue();
                if (deliveryState != null) {
                    try {
                        DeliveryStateFactory.create(deliveryState).accept(new DeliveryStateVisitorAdapter() {

                            public void visit(Accepted impl) {
                                deliveryMemory.deliverySettled(deliveryTag);
                                mySession.dispatch(new POSendResumedTransfer(Producer.this, deliveryTag));
                            }
                        });
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        if (deliveryMemory.getNumberUnsettled() > 0) {
            Collection<UnsettledDelivery> unsettled = deliveryMemory.getUnsettled();
            for (Iterator<UnsettledDelivery> iter = unsettled.iterator(); iter.hasNext(); ) {
                UnsettledDelivery unsettledDelivery = iter.next();
                if (unsettledDelivery.getMessage() != null) {
                    AMQPMessage msg = unsettledDelivery.getMessage();
                    if (msg.getTxnIdIF() == null) {
                        POSendMessage po = new POSendMessage(null, this, msg, null, unsettledDelivery.getDeliveryTag());
                        po.setRecovery(true);
                        mySession.dispatch(po);
                    }
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : DeliveryStateVisitorAdapter(com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateVisitorAdapter) POSendResumedTransfer(com.swiftmq.amqp.v100.client.po.POSendResumedTransfer) POSendMessage(com.swiftmq.amqp.v100.client.po.POSendMessage) IOException(java.io.IOException) DeliveryTag(com.swiftmq.amqp.v100.generated.transport.definitions.DeliveryTag) AMQPMessage(com.swiftmq.amqp.v100.messaging.AMQPMessage) Accepted(com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted) IOException(java.io.IOException) Iterator(java.util.Iterator) Map(java.util.Map)

Example 7 with Accepted

use of com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted in project swiftmq-ce by iitsoftware.

the class TargetLink method getLastDeliveryState.

public DeliveryStateIF getLastDeliveryState() {
    if (coordinator) {
        DeliveryStateIF ds = lastDeliveryState;
        lastDeliveryState = null;
        return ds;
    }
    return new Accepted();
}
Also used : DeliveryStateIF(com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF) Accepted(com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted)

Example 8 with Accepted

use of com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted in project swiftmq-client by iitsoftware.

the class SessionDispatcher method visit.

public void visit(POSendResumedTransfer po) {
    if (pTracer.isEnabled())
        pTracer.trace(toString(), ", visit, po=" + po + " ...");
    TransferFrame frame = new TransferFrame(mySession.getChannel());
    frame.setHandle(new Handle(po.getProducer().getHandle()));
    frame.setSettled(new AMQPBoolean(true));
    frame.setResume(new AMQPBoolean(true));
    frame.setDeliveryId(new DeliveryNumber(nextOutgoingId++));
    frame.setDeliveryTag(po.getDeliveryTag());
    frame.setState(new Accepted());
    outboundHandler.send(frame);
    if (pTracer.isEnabled())
        pTracer.trace(toString(), ", visit, po=" + po + " done");
}
Also used : Accepted(com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted)

Aggregations

Accepted (com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted)5 IOException (java.io.IOException)4 DeliveryStateIF (com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF)2 Declared (com.swiftmq.amqp.v100.generated.transactions.coordination.Declared)2 TransactionalState (com.swiftmq.amqp.v100.generated.transactions.coordination.TransactionalState)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 InvalidStateException (com.swiftmq.amqp.v100.client.InvalidStateException)1 POSendMessage (com.swiftmq.amqp.v100.client.po.POSendMessage)1 POSendResumedTransfer (com.swiftmq.amqp.v100.client.po.POSendResumedTransfer)1 DeliveryStateVisitorAdapter (com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateVisitorAdapter)1 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)1 DeliveryTag (com.swiftmq.amqp.v100.generated.transport.definitions.DeliveryTag)1 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)1 TopicImpl (com.swiftmq.jms.TopicImpl)1 MessageSelector (com.swiftmq.ms.MessageSelector)1 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)1 TopicException (com.swiftmq.swiftlet.topic.TopicException)1 DataByteArrayInputStream (com.swiftmq.tools.util.DataByteArrayInputStream)1 HashMap (java.util.HashMap)1