@Override public String toString() { return this.getClass().getSimpleName() + ":" + this.channel.getConnection().toString(); }
@Override public void close() throws TimeoutException, IOException { if (closed) { return; } if (logger.isDebugEnabled()) { logger.debug("Closing AMQP channel for " + this.channel.getConnection().toString()); } this.channel.close(); closed = true; }
private String getVersion() { return this.rabbitTemplate.execute((channel) -> channel.getConnection() .getServerProperties().get("version").toString()); }
@Override public Connection getConnection() { return this.delegate.getConnection(); }
@Override public Connection getConnection() { return this.delegate.getConnection(); }
@Override public Connection getConnection() { return delegate.getConnection(); }
public boolean isOk() { channel.getConnection().isOpen(); return true; }
/** * Gets the host of the used broker. * * @return the host */ public String getHost() { return channel.getConnection().getAddress().getHostName(); }
/** * Gets the port of the used broker. * * @return the port */ public int getPort() { return channel.getConnection().getPort(); }
public boolean isOk() { channel.getConnection().isOpen(); return true; }
@Override public boolean isOpen() { return delegate.isOpen() && delegate.getConnection().isOpen(); } @Override
@Override public String toString() { return "{" + "channelType=" + channelType + ", channelNo=" + delegate.getChannelNumber() + ", localPort=" + ((AMQConnection) delegate.getConnection()).getLocalPort() + '}'; } }
/** * Closes the connection to a channel. * @param channel the channel to close (can be null) * @throws IOException if something went wrong */ public static void closeConnection( Channel channel ) throws IOException { if( channel != null ) { if( channel.isOpen()) channel.close(); if( channel.getConnection().isOpen()) channel.getConnection().close(); } }
public static void close(Channel channel) throws Exception { channel.close(); channel.getConnection().close(); }
public void run() throws Exception { System.out.println("Starting supervisor"); Channel channel = AMQPCommon.connect(); connection = channel.getConnection(); startConsumer(); while (true) { long queueDepth = channel.messageCount("trade.eq.q"); long consumersNeeded = queueDepth/2; long diff = Math.abs(consumersNeeded - consumers.size()); for (int i=0;i<diff;i++) { if (consumersNeeded > consumers.size()) startConsumer(); else stopConsumer(); } Thread.sleep(1000); } }
public static void main(String[] args) throws Exception { AMQPContProducerNoFlow app = new AMQPContProducerNoFlow(); app.connection = AMQPCommon.connect().getConnection(); app.produceMessages(); }
public static void main(String[] args) throws Exception { AMQPContProducer app = new AMQPContProducer(); app.connection = AMQPCommon.connect().getConnection(); app.startListener(); app.produceMessages(); }
send_back.setConnection(getChannel().getConnection()); send_back.SendResponse(uuidRequest.toString(), jsonResult,routingKey);
@Subscribe private boolean unRegisterListener(JobStatusChangeEvent jobStatus, MonitorID monitorID) throws AiravataMonitorException { String channelID = CommonUtils.getChannelID(monitorID); if (JobState.FAILED.equals(jobStatus.getState()) || JobState.COMPLETE.equals(jobStatus.getState())){ Channel channel = availableChannels.get(channelID); if (channel == null) { logger.error("Already Unregistered the listener"); throw new AiravataMonitorException("Already Unregistered the listener"); } else { try { channel.queueUnbind(channel.queueDeclare().getQueue(), "glue2.computing_activity", CommonUtils.getRoutingKey(monitorID)); channel.close(); channel.getConnection().close(); availableChannels.remove(channelID); } catch (IOException e) { logger.error("Error unregistering the listener"); throw new AiravataMonitorException("Error unregistering the listener"); } } } return true; } }
try { template.execute(channel -> { channel.getConnection().addShutdownListener(cause -> { logger.info("Error", cause); latch.countDown();