/** * Creates a message sender asynchronously to the entity using the client settings. * @param namespaceName namespace name of entity * @param entityPath path of entity * @param clientSettings client settings * @return a CompletableFuture representing the pending creating of IMessageSender instance */ public static CompletableFuture<IMessageSender> createMessageSenderFromEntityPathAsync(String namespaceName, String entityPath, ClientSettings clientSettings) { Utils.assertNonNull("namespaceName", namespaceName); Utils.assertNonNull("entityPath", entityPath); return createMessageSenderFromEntityPathAsync(Util.convertNamespaceToEndPointURI(namespaceName), entityPath, clientSettings); }
/** * Creates a message sender to the entity using the client settings. * @param namespaceName namespace of entity * @param entityPath path of entity * @param clientSettings client settings * @return IMessageSender instance * @throws InterruptedException if the current thread was interrupted while waiting * @throws ServiceBusException if the sender cannot be created */ public static IMessageSender createMessageSenderFromEntityPath(String namespaceName, String entityPath, ClientSettings clientSettings) throws InterruptedException, ServiceBusException { return Utils.completeFuture(createMessageSenderFromEntityPathAsync(namespaceName, entityPath, clientSettings)); }
/** * Creates a message from a byte array. Message body type is set to binary. * @param content content of the message * @param contentType content type of the message */ public Message(byte[] content, String contentType) { this(Utils.fromBinay(content), contentType); }
brokeredMessage = new Message(Utils.fromBinay(messageData.getArray())); brokeredMessage = new Message(Utils.fromSequence(messageData));
amqpMessage.setBody(new AmqpSequence(Utils.getSequenceFromMessageBody(body))); amqpMessage.setBody(new Data(new Binary(Utils.getDataFromMessageBody(body))));
@Override @Deprecated public byte[] getBody() { return Utils.getDataFromMessageBody(this.messageBody); }
/** * Creates a message sender to the entity using the client settings. * @param namespaceEndpointURI endpoint uri of entity namespace * @param entityPath path of entity * @param clientSettings client settings * @return IMessageSender instance * @throws InterruptedException if the current thread was interrupted while waiting * @throws ServiceBusException if the sender cannot be created */ public static IMessageSender createMessageSenderFromEntityPath(URI namespaceEndpointURI, String entityPath, ClientSettings clientSettings) throws InterruptedException, ServiceBusException { return Utils.completeFuture(createMessageSenderFromEntityPathAsync(namespaceEndpointURI, entityPath, clientSettings)); }
/** * Asynchronously creates a message receiver to the entity using the client settings * @param namespaceEndpointURI endpoint uri of entity namespace * @param entityPath path of entity * @param clientSettings client settings * @param receiveMode PeekLock or ReceiveAndDelete * @return a CompletableFuture representing the pending creation of message receiver */ public static CompletableFuture<IMessageReceiver> createMessageReceiverFromEntityPathAsync(URI namespaceEndpointURI, String entityPath, ClientSettings clientSettings, ReceiveMode receiveMode) { Utils.assertNonNull("namespaceEndpointURI", namespaceEndpointURI); Utils.assertNonNull("entityPath", entityPath); MessageReceiver receiver = new MessageReceiver(namespaceEndpointURI, entityPath, null, clientSettings, receiveMode); return receiver.initializeAsync().thenApply((v) -> receiver); }
/** * Creates a message from a byte array. Message body type is set to binary. * @param messageId id of the message * @param content content of the message * @param contentType content type of the message */ public Message(String messageId, byte[] content, String contentType) { this(messageId, Utils.fromBinay(content), contentType); }
/** * Creates a message receiver to the entity using the client settings in PeekLock mode * @param namespaceName namespace of entity * @param entityPath path of the entity * @param clientSettings client settings * @return IMessageReceiver instance * @throws InterruptedException if the current thread was interrupted while waiting * @throws ServiceBusException if the receiver cannot be created */ public static IMessageReceiver createMessageReceiverFromEntityPath(String namespaceName, String entityPath, ClientSettings clientSettings) throws InterruptedException, ServiceBusException { return Utils.completeFuture(createMessageReceiverFromEntityPathAsync(namespaceName, entityPath, clientSettings)); }
/** * Asynchronously accepts a session from service bus using the client settings. Session Id can be null, if null, service will return the first available session. * @param namespaceEndpointURI endpoint uri of entity namespace * @param entityPath path of entity * @param sessionId session id, if null, service will return the first available session, otherwise, service will return specified session * @param clientSettings client settings * @param receiveMode PeekLock or ReceiveAndDelete * @return a CompletableFuture representing the pending session accepting */ public static CompletableFuture<IMessageSession> acceptSessionFromEntityPathAsync(URI namespaceEndpointURI, String entityPath, String sessionId, ClientSettings clientSettings, ReceiveMode receiveMode) { Utils.assertNonNull("namespaceEndpointURI", namespaceEndpointURI); Utils.assertNonNull("entityPath", entityPath); MessageSession session = new MessageSession(namespaceEndpointURI, entityPath, null, sessionId, clientSettings, receiveMode); return session.initializeAsync().thenApply((v) -> session); }
/** * Creates a message from a byte array. Message body type is set to binary. * @param content content of the message */ public Message(byte[] content) { this(Utils.fromBinay(content)); }
/** * Retrieves the list of topics present in the namespace. * @return the first 100 topics. * @throws TimeoutException - The operation times out. The timeout period is initiated through ClientSettings.operationTimeout * @throws AuthorizationFailedException - No sufficient permission to perform this operation. Please check ClientSettings.tokenProvider has correct details. * @throws ServerBusyException - The server is busy. You should wait before you retry the operation. * @throws ServiceBusException - An internal error or an unexpected exception occured. */ public List<TopicDescription> getTopics() throws ServiceBusException, InterruptedException { return Utils.completeFuture(this.asyncClient.getTopicsAsync()); }
static CompletableFuture<IMessageSender> createMessageSenderFromEntityPathAsync(URI namespaceEndpointURI, String entityPath, MessagingEntityType entityType, ClientSettings clientSettings) { Utils.assertNonNull("namespaceEndpointURI", namespaceEndpointURI); MessageSender sender = new MessageSender(namespaceEndpointURI, entityPath, null, entityType, clientSettings); return sender.initializeAsync().thenApply((v) -> sender); }
@Override @Deprecated public void setBody(byte[] body) { this.messageBody = Utils.fromBinay(body); }
/** * Creates a message receiver to the entity using the client settings in PeekLock mode * @param namespaceEndpointURI endpoint uri of entity namespace * @param entityPath path of the entity * @param clientSettings client settings * @return IMessageReceiver instance * @throws InterruptedException if the current thread was interrupted while waiting * @throws ServiceBusException if the receiver cannot be created */ public static IMessageReceiver createMessageReceiverFromEntityPath(URI namespaceEndpointURI, String entityPath, ClientSettings clientSettings) throws InterruptedException, ServiceBusException { return Utils.completeFuture(createMessageReceiverFromEntityPathAsync(namespaceEndpointURI, entityPath, clientSettings)); }
static CompletableFuture<IMessageSender> createMessageSenderFromEntityPathAsync(MessagingFactory messagingFactory, String entityPath, MessagingEntityType entityType) { Utils.assertNonNull("messagingFactory", messagingFactory); MessageSender sender = new MessageSender(messagingFactory, entityPath, entityType); return sender.initializeAsync().thenApply((v) -> sender); }
/** * Creates a message receiver to the entity. * @param messagingFactory messaging factory (which represents a connection) on which receiver needs to be created * @param entityPath path of the entity * @param receiveMode PeekLock or ReceiveAndDelete * @return IMessageReceiver instance * @throws InterruptedException if the current thread was interrupted while waiting * @throws ServiceBusException if the receiver cannot be created */ public static IMessageReceiver createMessageReceiverFromEntityPath(MessagingFactory messagingFactory, String entityPath, ReceiveMode receiveMode) throws InterruptedException, ServiceBusException { return Utils.completeFuture(createMessageReceiverFromEntityPathAsync(messagingFactory, entityPath, receiveMode)); }
static CompletableFuture<IMessageSession> acceptSessionFromEntityPathAsync(MessagingFactory messagingFactory, String entityPath, MessagingEntityType entityType, String sessionId, ReceiveMode receiveMode) { Utils.assertNonNull("messagingFactory", messagingFactory); MessageSession session = new MessageSession(messagingFactory, entityPath, entityType, sessionId, receiveMode); return session.initializeAsync().thenApply((v) -> session); } }
QueueClient(MessagingFactory factory, String queuePath, ReceiveMode receiveMode) throws InterruptedException, ServiceBusException { this(receiveMode, queuePath); Utils.completeFuture(this.createInternals(factory, queuePath, receiveMode)); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info("Created queue client to queue '{}'", queuePath); } }