use of org.apache.qpid.proton.amqp.transport.ErrorCondition in project azure-service-bus-java by Azure.
the class ConnectionHandler method onConnectionRemoteClose.
@Override
public void onConnectionRemoteClose(Event event) {
final Connection connection = event.getConnection();
final ErrorCondition error = connection.getRemoteCondition();
TRACE_LOGGER.debug("onConnectionRemoteClose: hostname:{},errorCondition:{}", connection.getHostname(), error != null ? error.getCondition() + "," + error.getDescription() : null);
boolean shouldFreeConnection = connection.getLocalState() == EndpointState.CLOSED;
this.messagingFactory.onConnectionError(error);
if (shouldFreeConnection) {
connection.free();
}
}
use of org.apache.qpid.proton.amqp.transport.ErrorCondition in project azure-iot-sdk-java by Azure.
the class AmqpsIotHubConnection method onConnectionRemoteClose.
@Override
public void onConnectionRemoteClose(Event event) {
Connection connection = event.getConnection();
if (connection.getLocalState() == EndpointState.ACTIVE) {
ErrorCondition errorCondition = connection.getRemoteCondition();
this.savedException = AmqpsExceptionTranslator.convertFromAmqpException(errorCondition);
log.error("Amqp connection was closed remotely", this.savedException);
this.connection.close();
} else {
log.trace("Closing reactor since connection has closed");
event.getReactor().stop();
}
}
use of org.apache.qpid.proton.amqp.transport.ErrorCondition in project azure-iot-sdk-java by Azure.
the class AmqpsIotHubConnection method onTransportError.
@Override
public void onTransportError(Event event) {
super.onTransportError(event);
this.state = IotHubConnectionStatus.DISCONNECTED;
// Error may be on remote, and it may be local
ErrorCondition errorCondition = event.getTransport().getRemoteCondition();
// Sometimes the remote errorCondition object is not null, but all of its fields are null. In this case, check the local error condition
// for the error details.
boolean isALocalErrorCondition = false;
if (errorCondition == null || (errorCondition.getCondition() == null && errorCondition.getDescription() == null && errorCondition.getInfo() == null)) {
errorCondition = event.getTransport().getCondition();
isALocalErrorCondition = true;
}
this.savedException = AmqpsExceptionTranslator.convertFromAmqpException(errorCondition);
// onConnectionLocalClose. Proton will not queue the CONNECTION_LOCAL_CLOSE event since the Endpoint status is CLOSED
if (event.getConnection().getLocalState() == EndpointState.CLOSED && isALocalErrorCondition) {
log.error("Amqp transport error occurred, calling onConnectionLocalClose", this.savedException);
onConnectionLocalClose(event);
} else {
log.error("Amqp transport error occurred, closing the AMQPS connection", this.savedException);
event.getConnection().close();
}
}
use of org.apache.qpid.proton.amqp.transport.ErrorCondition in project azure-iot-sdk-java by Azure.
the class AmqpFeedbackReceivedHandlerTest method createProtonObjects.
private void createProtonObjects() {
final String exceptionMessage = "Not expected function called";
message = Proton.message();
receiver = new Receiver() {
@Override
public void flow(int i) {
}
@Override
public int recv(byte[] bytes, int i, int i1) {
return 0;
}
@Override
public ReadableBuffer recv() {
return readBuf;
}
@Override
public int recv(WritableBuffer writableBuffer) {
return 0;
}
@Override
public void drain(int i) {
}
@Override
public boolean advance() {
return false;
}
@Override
public boolean draining() {
return false;
}
@Override
public void setDrain(boolean b) {
}
@Override
public String getName() {
return RECEIVE_TAG;
}
@Override
public Delivery delivery(byte[] bytes) {
return null;
}
@Override
public Delivery delivery(byte[] bytes, int i, int i1) {
return null;
}
@Override
public Delivery head() {
return null;
}
@Override
public Delivery current() {
return delivery;
}
@Override
public org.apache.qpid.proton.amqp.transport.Source getSource() {
return null;
}
@Override
public org.apache.qpid.proton.amqp.transport.Target getTarget() {
return null;
}
@Override
public void setSource(org.apache.qpid.proton.amqp.transport.Source source) {
}
@Override
public void setTarget(org.apache.qpid.proton.amqp.transport.Target target) {
}
@Override
public org.apache.qpid.proton.amqp.transport.Source getRemoteSource() {
return null;
}
@Override
public org.apache.qpid.proton.amqp.transport.Target getRemoteTarget() {
return null;
}
@Override
public Link next(EnumSet<EndpointState> enumSet, EnumSet<EndpointState> enumSet1) {
return null;
}
@Override
public int getCredit() {
return 0;
}
@Override
public int getQueued() {
return 0;
}
@Override
public int getUnsettled() {
return 0;
}
@Override
public Session getSession() {
return session;
}
@Override
public SenderSettleMode getSenderSettleMode() {
return null;
}
@Override
public void setSenderSettleMode(SenderSettleMode senderSettleMode) {
}
@Override
public SenderSettleMode getRemoteSenderSettleMode() {
return null;
}
@Override
public ReceiverSettleMode getReceiverSettleMode() {
return null;
}
@Override
public void setReceiverSettleMode(ReceiverSettleMode receiverSettleMode) {
}
@Override
public ReceiverSettleMode getRemoteReceiverSettleMode() {
return null;
}
@Override
public void setRemoteSenderSettleMode(SenderSettleMode senderSettleMode) {
}
@Override
public Map<Symbol, Object> getProperties() {
return null;
}
@Override
public void setProperties(Map<Symbol, Object> map) {
}
@Override
public Map<Symbol, Object> getRemoteProperties() {
return null;
}
@Override
public int drained() {
return 0;
}
@Override
public int getRemoteCredit() {
return 0;
}
@Override
public boolean getDrain() {
return false;
}
@Override
public void detach() {
}
@Override
public boolean detached() {
return false;
}
@Override
public void setOfferedCapabilities(Symbol[] symbols) {
}
@Override
public Symbol[] getOfferedCapabilities() {
return new Symbol[0];
}
@Override
public Symbol[] getRemoteOfferedCapabilities() {
return new Symbol[0];
}
@Override
public void setDesiredCapabilities(Symbol[] symbols) {
}
@Override
public Symbol[] getDesiredCapabilities() {
return new Symbol[0];
}
@Override
public Symbol[] getRemoteDesiredCapabilities() {
return new Symbol[0];
}
@Override
public void setMaxMessageSize(UnsignedLong unsignedLong) {
}
@Override
public UnsignedLong getMaxMessageSize() {
return null;
}
@Override
public UnsignedLong getRemoteMaxMessageSize() {
return null;
}
@Override
public EndpointState getLocalState() {
return null;
}
@Override
public EndpointState getRemoteState() {
return null;
}
@Override
public ErrorCondition getCondition() {
return null;
}
@Override
public void setCondition(ErrorCondition errorCondition) {
}
@Override
public ErrorCondition getRemoteCondition() {
return null;
}
@Override
public void free() {
}
@Override
public void open() {
}
@Override
public void close() {
}
@Override
public void setContext(Object o) {
}
@Override
public Object getContext() {
return null;
}
@Override
public Record attachments() {
return null;
}
};
event = new Event() {
@Override
public EventType getEventType() {
return null;
}
@Override
public Event.Type getType() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Object getContext() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Handler getRootHandler() {
return null;
}
@Override
public void dispatch(Handler hndlr) throws HandlerException {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public void redispatch(EventType eventType, Handler handler) throws HandlerException {
}
@Override
public void delegate() throws HandlerException {
}
@Override
public Connection getConnection() {
return connection;
}
@Override
public Session getSession() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Link getLink() {
return receiver;
}
@Override
public Sender getSender() {
return null;
}
@Override
public Receiver getReceiver() {
return null;
}
@Override
public Delivery getDelivery() {
return delivery;
}
@Override
public Transport getTransport() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Reactor getReactor() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Selectable getSelectable() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Task getTask() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Event copy() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Record attachments() {
throw new UnsupportedOperationException(exceptionMessage);
}
};
delivery = new Delivery() {
@Override
public byte[] getTag() {
return new byte[0];
}
@Override
public Link getLink() {
return receiver;
}
@Override
public DeliveryState getLocalState() {
return null;
}
@Override
public DeliveryState getRemoteState() {
return null;
}
@Override
public int getMessageFormat() {
return 0;
}
@Override
public int available() {
return 0;
}
@Override
public void disposition(DeliveryState deliveryState) {
}
@Override
public void settle() {
}
@Override
public boolean isSettled() {
return false;
}
@Override
public boolean isAborted() {
return false;
}
@Override
public boolean remotelySettled() {
return false;
}
@Override
public void free() {
}
@Override
public Delivery getWorkNext() {
return null;
}
@Override
public Delivery next() {
return null;
}
@Override
public boolean isWritable() {
return false;
}
@Override
public boolean isReadable() {
return true;
}
@Override
public void setContext(Object o) {
}
@Override
public Object getContext() {
return null;
}
@Override
public boolean isUpdated() {
return false;
}
@Override
public void clear() {
}
@Override
public boolean isPartial() {
return false;
}
@Override
public int pending() {
return 0;
}
@Override
public boolean isBuffered() {
return false;
}
@Override
public void setDefaultDeliveryState(DeliveryState deliveryState) {
}
@Override
public DeliveryState getDefaultDeliveryState() {
return null;
}
@Override
public void setMessageFormat(int i) {
}
@Override
public Record attachments() {
return null;
}
};
}
use of org.apache.qpid.proton.amqp.transport.ErrorCondition in project vertx-proton by vert-x3.
the class DeliveryPublisherVerificationTckTest method createServer.
private TestServer createServer() throws Exception {
return new TestServer(vertx, (connection) -> {
connection.openHandler(res -> {
LOG.trace("Client connected: " + connection.getRemoteContainer());
connection.open();
}).closeHandler(c -> {
LOG.trace("Client closing amqp connection: " + connection.getRemoteContainer());
connection.close();
connection.disconnect();
}).disconnectHandler(c -> {
LOG.trace("Client socket disconnected: " + connection.getRemoteContainer());
connection.disconnect();
}).sessionOpenHandler(session -> session.open());
connection.senderOpenHandler(sender -> {
if (!server.getDetachLink()) {
LOG.trace("Sending to client from: " + sender.getRemoteSource().getAddress());
// This is rather naive, for example use only, proper
sender.setSource(sender.getRemoteSource());
// servers should ensure that they advertise their own
// Source settings that actually reflect what is in place.
// The request may have also been for a dynamic address.
AtomicLong count = new AtomicLong();
AtomicLong outstanding = new AtomicLong();
sender.sendQueueDrainHandler(s -> {
while (!s.sendQueueFull()) {
LOG.trace("Sending message to client");
Message m = message("Hello World from Server!" + count.incrementAndGet());
outstanding.incrementAndGet();
s.send(m, delivery -> {
LOG.trace("The message was received by the client.");
});
}
});
sender.closeHandler(s -> {
s.result().close();
});
}
sender.open();
if (server.getDetachLink()) {
sender.setCondition(new ErrorCondition(Symbol.getSymbol("Failed Publisher Requested"), ""));
sender.close();
}
});
});
}
Aggregations