Refine search
private Rejected createRejected(Symbol amqpError, String message) { Rejected rejected = new Rejected(); ErrorCondition condition = new ErrorCondition(); condition.setCondition(amqpError); condition.setDescription(message); rejected.setError(condition); return rejected; }
public Object get(final int index) { switch(index) { case 0: return _errorCondition.getCondition(); case 1: return _errorCondition.getDescription(); case 2: return _errorCondition.getInfo(); } throw new IllegalStateException("Unknown index " + index); }
public End(End other) { if (other._error != null) { this._error = new ErrorCondition(); this._error.copyFrom(other._error); } }
public int size() { return _errorCondition.getInfo() != null ? 3 : _errorCondition.getDescription() != null ? 2 : 1; }
try { if (response.isException()) { protonConnection.setProperties(getFailedConnetionProperties()); protonConnection.open(); protonConnection.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); } else if (exception instanceof InvalidClientIDException) { ErrorCondition condition = new ErrorCondition(AmqpError.INVALID_FIELD, exception.getMessage()); condition.setInfo(infoMap); protonConnection.setCondition(condition); } else { protonConnection.setCondition(new ErrorCondition(AmqpError.ILLEGAL_STATE, exception.getMessage())); if (amqpTransport.isUseInactivityMonitor() && amqpWireFormat.getIdleTimeout() > 0) { LOG.trace("Connection requesting Idle timeout of: {} mills", amqpWireFormat.getIdleTimeout()); protonTransport.setIdleTimeout(amqpWireFormat.getIdleTimeout());
private void handleBound(Reactor reactor, Event event) { Connection connection = event.getConnection(); String hostname = connection.getHostname(); if (hostname == null || hostname.equals("")) { return; Transport transport = event.getConnection().getTransport(); socket = socketChannel.socket(); } catch(IOException ioException) { ErrorCondition condition = new ErrorCondition(); condition.setCondition(Symbol.getSymbol("proton:io")); condition.setDescription(ioException.getMessage()); transport.setCondition(condition); transport.close_tail(); transport.close_head(); transport.pop(transport.pending()); // Force generation of TRANSPORT_HEAD_CLOSE (not in C code)
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); Transport transport = ((SelectableImpl)selectable).getTransport(); int capacity = transport.capacity(); if (capacity > 0) { SocketChannel socketChannel = (SocketChannel)selectable.getChannel(); try { int n = socketChannel.read(transport.tail()); if (n == -1) { transport.close_tail(); } else { transport.process(); } } catch (IOException | TransportException e) { ErrorCondition condition = new ErrorCondition(); condition.setCondition(Symbol.getSymbol("proton:io")); condition.setDescription(e.getMessage()); transport.setCondition(condition); transport.close_tail(); } } // (Comment from C code:) occasionally transport events aren't // generated when expected, so the following hack ensures we // always update the selector update(selectable); reactor.update(selectable); } };
/** * Send a "rejected" delivery to the AMQP remote sender * * @param linkName AMQP link name * @param delivery AMQP delivery * @param cause exception related to the rejection cause */ private void rejectedDelivery(String linkName, ProtonDelivery delivery, Throwable cause) { Rejected rejected = new Rejected(); rejected.setError(new ErrorCondition(Symbol.valueOf(AmqpBridge.AMQP_ERROR_SEND_TO_KAFKA), cause.getMessage())); delivery.disposition(rejected, true); log.debug("Delivery sent [rejected] on link {}", linkName); }
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); Transport transport = ((SelectableImpl)selectable).getTransport(); int pending = transport.pending(); if (pending > 0) { SocketChannel channel = (SocketChannel)selectable.getChannel(); try { int n = channel.write(transport.head()); if (n < 0) { transport.close_head(); } else { transport.pop(n); } } catch(IOException ioException) { ErrorCondition condition = new ErrorCondition(); condition.setCondition(Symbol.getSymbol("proton:io")); condition.setDescription(ioException.getMessage()); transport.setCondition(condition); transport.close_head(); } } int newPending = transport.pending(); if (newPending != pending) { update(selectable); reactor.update(selectable); } } };
@Override public long tick(boolean firstTick) { if (!firstTick) { try { if (connection.getLocalState() != EndpointState.CLOSED) { long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); if (transport.isClosed()) { throw new IllegalStateException("Channel was inactive for to long"); } return rescheduleAt; } } catch (Exception e) { transport.close(); connection.setCondition(new ErrorCondition()); } return 0; } return transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime())); }
@Override public void onConnectionLocalClose(Event event) { final Connection connection = event.getConnection(); final ErrorCondition error = connection.getCondition(); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onConnectionLocalClose: hostname[%s], errorCondition[%s], errorDescription[%s]", connection.getHostname(), error != null ? error.getCondition() : "n/a", error != null ? error.getDescription() : "n/a")); } if (connection.getRemoteState() == EndpointState.CLOSED) { // This means that the CLOSE origin is Service final Transport transport = connection.getTransport(); if (transport != null) { transport.unbind(); // we proactively dispose IO even if service fails to close } } }
@Override public void onSessionFinal(Event e) { if (TRACE_LOGGER.isInfoEnabled()) { final Session session = e.getSession(); ErrorCondition condition = session != null ? session.getCondition() : null; TRACE_LOGGER.info(String.format(Locale.US, "onSessionFinal entityName[%s], condition[%s], description[%s]", this.entityName, condition != null ? condition.getCondition() : "n/a", condition != null ? condition.getDescription() : "n/a")); } }
public ErrorCondition newInstance(Object described) { List l = (List) described; ErrorCondition o = new ErrorCondition(); if(l.isEmpty()) { throw new DecodeException("The condition field cannot be omitted"); } switch(3 - l.size()) { case 0: o.setInfo( (Map) l.get( 2 ) ); case 1: o.setDescription( (String) l.get( 1 ) ); case 2: o.setCondition( (Symbol) l.get( 0 ) ); } return o; }
@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(); } }
private void internalHandlerError(Exception e) { log.warn(e.getMessage(), e); ErrorCondition error = new ErrorCondition(); error.setCondition(AmqpError.INTERNAL_ERROR); error.setDescription("Unrecoverable error: " + (e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage())); connection.setCondition(error); connection.close(); flush(); }
private void processEventSessionRemoteState(Event event) { final String methodName = "processEventSessionRemoteState"; logger.entry(this, methodName, event); if (event.getSession().getRemoteState() == EndpointState.ACTIVE) { if (event.getSession().getLocalState() == EndpointState.ACTIVE) { final EngineConnection engineConnection = (EngineConnection) event.getConnection().getContext(); if (!engineConnection.closed) { // First session has opened on the connection OpenRequest req = engineConnection.openRequest; engineConnection.openRequest = null; engineConnection.requestor.tell(new OpenResponse(req, engineConnection), this); } } else { // The remote end is trying to establish a new session with us, which is not allowed. I don't think this is a usual case, // but could occur with a badly written remote end (i.e. sends an initial AMQP open immediately followed by a begin) final Connection protonConnection = event.getConnection(); protonConnection.setCondition(new ErrorCondition(Symbol.getSymbol("mqlight:session-remote-open-rejected"), "MQ Light client is unable to accept an open session request")); protonConnection.close(); } } logger.exit(this, methodName); }
private ClientException getClientException(ErrorCondition errorCondition) { final String methodName = "getClientException"; logger.entry(this, methodName, errorCondition); ClientException result = null; if (errorCondition != null && errorCondition.getCondition() != null) { if (errorCondition.getCondition() == LinkError.STOLEN) { result = new ReplacedException(errorCondition.getDescription()); } else if (errorCondition.getCondition().equals(AmqpError.PRECONDITION_FAILED) || errorCondition.getCondition().equals(AmqpError.NOT_ALLOWED) || errorCondition.getCondition().equals(AmqpError.NOT_IMPLEMENTED) || errorCondition.getDescription().contains("_InvalidSourceTimeout")) { result = new NotPermittedException(errorCondition.getDescription()); } if (result == null && errorCondition.getDescription() != null) { if (errorCondition.getDescription().contains("sasl ") || errorCondition.getDescription().contains("SSL ")) { result = new com.ibm.mqlight.api.SecurityException(errorCondition.getDescription()); } } if (result == null) { String msg = errorCondition.getCondition().toString(); if (errorCondition.getDescription() != null) { msg += ": " + errorCondition.getDescription(); } result = new NetworkException(msg); } } logger.exit(this, methodName, result); return result; }
ErrorCondition errorCond = rejectedState.getError(); this.errorCondition = errorCond.getCondition(); this.errorDescription = errorCond.getDescription(); this.errorInfo = errorCond.getInfo(); this.amqpResponseVerifier();
/** * Create a new AMQP error condition * * @param error AMQP error * @param description description for the AMQP error condition * @return AMQP error condition */ static ErrorCondition newError(String error, String description) { return new ErrorCondition(Symbol.getSymbol(error), description); }
public CompletableFuture<Void> deadLetterMessageAsync( byte[] deliveryTag, String deadLetterReason, String deadLetterErrorDescription, Map<String, Object> propertiesToModify, TransactionContext transaction) { Rejected outcome = new Rejected(); ErrorCondition error = new ErrorCondition(ClientConstants.DEADLETTERNAME, null); Map<String, Object> errorInfo = new HashMap<String, Object>(); if(!StringUtil.isNullOrEmpty(deadLetterReason)) { errorInfo.put(ClientConstants.DEADLETTER_REASON_HEADER, deadLetterReason); } if(!StringUtil.isNullOrEmpty(deadLetterErrorDescription)) { errorInfo.put(ClientConstants.DEADLETTER_ERROR_DESCRIPTION_HEADER, deadLetterErrorDescription); } if(propertiesToModify != null) { errorInfo.putAll(propertiesToModify); } error.setInfo(errorInfo); outcome.setError(error); return this.updateMessageStateAsync(deliveryTag, outcome, transaction); }