Search in sources :

Example 16 with AMQPBoolean

use of com.swiftmq.amqp.v100.types.AMQPBoolean in project swiftmq-client by iitsoftware.

the class AMQPRepo method remove.

AMQPRepo remove(String appname) throws Exception {
    AMQPMessage request = new AMQPMessage();
    Map propMap = new HashMap();
    propMap.put(new AMQPString("app"), new AMQPString(appname));
    propMap.put(new AMQPString("operation"), new AMQPString("remove"));
    request.setApplicationProperties(new ApplicationProperties(propMap));
    Properties properties = new Properties();
    properties.setReplyTo(replyQueue);
    request.setProperties(properties);
    producer.send(request);
    AMQPMessage reply = consumer.receive(TIMEOUT);
    if (reply == null)
        throw new Exception("Timeout occurred while waiting for a reply!");
    AMQPMap body = (AMQPMap) reply.getAmqpValue().getValue();
    boolean success = ((AMQPBoolean) (body.getValue().get(new AMQPString("success")))).getValue();
    if (success)
        System.out.println("Removed repository " + appname);
    else {
        String result = ((AMQPString) (body.getValue().get(new AMQPString("result")))).getValue();
        System.out.println(result);
    }
    return this;
}
Also used : AMQPMap(com.swiftmq.amqp.v100.types.AMQPMap) HashMap(java.util.HashMap) ApplicationProperties(com.swiftmq.amqp.v100.generated.messaging.message_format.ApplicationProperties) AMQPString(com.swiftmq.amqp.v100.types.AMQPString) AMQPString(com.swiftmq.amqp.v100.types.AMQPString) ApplicationProperties(com.swiftmq.amqp.v100.generated.messaging.message_format.ApplicationProperties) Properties(com.swiftmq.amqp.v100.generated.messaging.message_format.Properties) AMQPBoolean(com.swiftmq.amqp.v100.types.AMQPBoolean) AMQPMessage(com.swiftmq.amqp.v100.messaging.AMQPMessage) AMQPMap(com.swiftmq.amqp.v100.types.AMQPMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with AMQPBoolean

use of com.swiftmq.amqp.v100.types.AMQPBoolean 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)

Example 18 with AMQPBoolean

use of com.swiftmq.amqp.v100.types.AMQPBoolean in project swiftmq-client by iitsoftware.

the class TransactionController method discharge.

private synchronized void discharge(TxnIdIF txnId, boolean fail) throws AMQPException {
    AMQPMessage msg = new AMQPMessage();
    Discharge discharge = new Discharge();
    discharge.setTxnId(txnId);
    discharge.setFail(new AMQPBoolean(fail));
    msg.setAmqpValue(new AmqpValue(discharge));
    DeliveryStateIF deliveryState = producer.send(msg);
    if (deliveryState instanceof Rejected) {
        Rejected rejected = (Rejected) deliveryState;
        com.swiftmq.amqp.v100.generated.transport.definitions.Error error = rejected.getError();
        if (error != null)
            throw new AMQPException(error.getValueString());
        else
            throw new AMQPException(("Unknown transactiom error"));
    }
}
Also used : DeliveryStateIF(com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF) Rejected(com.swiftmq.amqp.v100.generated.messaging.delivery_state.Rejected) AMQPBoolean(com.swiftmq.amqp.v100.types.AMQPBoolean) AMQPMessage(com.swiftmq.amqp.v100.messaging.AMQPMessage) AmqpValue(com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)

Aggregations

IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)7 List (java.util.List)7 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)6 Properties (com.swiftmq.amqp.v100.generated.messaging.message_format.Properties)5 AMQPBoolean (com.swiftmq.amqp.v100.types.AMQPBoolean)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ApplicationProperties (com.swiftmq.amqp.v100.generated.messaging.message_format.ApplicationProperties)4 Milliseconds (com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds)4 AMQPMap (com.swiftmq.amqp.v100.types.AMQPMap)4 AMQPString (com.swiftmq.amqp.v100.types.AMQPString)4 AmqpValue (com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)2 TransactionalState (com.swiftmq.amqp.v100.generated.transactions.coordination.TransactionalState)2 TxnIdIF (com.swiftmq.amqp.v100.generated.transactions.coordination.TxnIdIF)2 Fields (com.swiftmq.amqp.v100.generated.transport.definitions.Fields)2 Handle (com.swiftmq.amqp.v100.generated.transport.definitions.Handle)2 Seconds (com.swiftmq.amqp.v100.generated.transport.definitions.Seconds)2 SequenceNo (com.swiftmq.amqp.v100.generated.transport.definitions.SequenceNo)2 AMQPException (com.swiftmq.amqp.v100.client.AMQPException)1