public static StompControlFrame newAbortFrame(String transactionId) { StompControlFrame frame = new StompControlFrame( Command.ABORT ); frame.setHeader( Header.TRANSACTION, transactionId ); return frame; }
public static StompFrame newReceiptFrame(String receiptId) { StompControlFrame receipt = new StompControlFrame( Command.RECEIPT ); receipt.setHeader( Header.RECEIPT_ID, receiptId ); return receipt; }
public static StompControlFrame newBeginFrame(String transactionId) { StompControlFrame frame = new StompControlFrame( Command.BEGIN ); frame.setHeader( Header.TRANSACTION, transactionId ); return frame; }
public static StompFrame newConnectedFrame(String sessionId, Version version) { StompControlFrame frame = new StompControlFrame( Command.CONNECTED ); frame.setHeader( Header.SESSION, sessionId ); String implVersion = StompFrames.class.getPackage().getImplementationVersion(); frame.setHeader( Header.SERVER, "Stilts/" + implVersion ); if (version.isAfter( Version.VERSION_1_0 )) { frame.setHeader( Header.VERSION, version.versionString() ); } return frame; }
public static StompControlFrame newCommitFrame(String transactionId) { StompControlFrame frame = new StompControlFrame( Command.COMMIT ); frame.setHeader( Header.TRANSACTION, transactionId ); return frame; }
public static StompFrame newAckFrame(Headers headers) { StompControlFrame frame = new StompControlFrame( Command.ACK ); frame.setHeader( Header.MESSAGE_ID, headers.get( Header.MESSAGE_ID ) ); frame.setHeader( Header.SUBSCRIPTION, headers.get( Header.SUBSCRIPTION ) ); String transactionId = headers.get( Header.TRANSACTION ); if (transactionId != null) { frame.setHeader( Header.TRANSACTION, transactionId ); } return frame; }
public static StompFrame newNackFrame(Headers headers) { StompControlFrame frame = new StompControlFrame( Command.NACK ); frame.setHeader( Header.MESSAGE_ID, headers.get( Header.MESSAGE_ID ) ); frame.setHeader( Header.SUBSCRIPTION, headers.get( Header.SUBSCRIPTION ) ); String transactionId = headers.get( Header.TRANSACTION ); if (transactionId != null) { frame.setHeader( Header.TRANSACTION, transactionId ); } return frame; }
@Override public void channelConnected(ChannelHandlerContext context, ChannelStateEvent e) throws Exception { StompControlFrame frame = new StompControlFrame( Command.CONNECT ); frame.setHeader( Header.HOST, this.host ); frame.setHeader( Header.ACCEPT_VERSION, Version.supportedVersions() ); Channels.write( context.getChannel(), frame ); }
void unsubscribe(ClientSubscription subscription) throws InterruptedException, ExecutionException { StompControlFrame frame = new StompControlFrame( Command.UNSUBSCRIBE ); frame.setHeader( Header.ID, subscription.getId() ); sendFrame( frame ).await(); subscription.setActive( false ); }
ClientSubscription subscribe(SubscriptionBuilderImpl builder) throws InterruptedException, ExecutionException { StompControlFrame frame = new StompControlFrame( Command.SUBSCRIBE, builder.getHeaders() ); String subscriptionId = getNextSubscriptionId(); frame.setHeader( Header.ID, subscriptionId ); ReceiptFuture future = sendFrame( frame ); future.await(); if (future.isError()) { return null; } else { Executor executor = builder.getExecutor(); if (executor == null) { executor = getExecutor(); } ClientSubscription subscription = new ClientSubscription( this, subscriptionId, builder.getMessageHandler(), executor ); this.subscriptions.put( subscription.getId(), subscription ); return subscription; } }