MessageSender mgsSender = new MessageSender(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { MessageSenderContent mgsContent = createMegContent(registration_Id, your_title); mgsSender.sendPost(mgsContent) return null; } }.execute();
@Override public void send(IMessage message) throws InterruptedException, ServiceBusException { this.send(message, TransactionContext.NULL_TXN); }
@Override public CompletableFuture<Long> scheduleMessageAsync(IMessage message, Instant scheduledEnqueueTimeUtc) { return this.scheduleMessageAsync(message, scheduledEnqueueTimeUtc, TransactionContext.NULL_TXN); }
data.setMsg(msg); java.io.StringWriter sw = new StringWriter(); Marshaller.marshal(data, sw); xmlString = sw.toString(); MessageSender msgsender = new MessageSender(); msgsender.sendMessageToApplication(xmlString);
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); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_list); content = (TextView)findViewById(R.id.output); content.setText("Select user to chat:"); refreshButton = (Button)findViewById(R.id.refreshButton); intent = new Intent(this, GCMNotificationIntentService.class); registerReceiver(broadcastReceiver, new IntentFilter("com.javapapers.android.gcm.chat.userlist")); messageSender = new MessageSender(); gcm = GoogleCloudMessaging.getInstance(getApplicationContext()); refreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // get user list Bundle dataBundle = new Bundle(); dataBundle.putString("ACTION", "USERLIST"); messageSender.sendMessage(dataBundle, gcm); } }); unregisterReceiver(broadcastReceiver); }
peekFuture = this.messageReceiver.getInternalReceiver().peekMessagesAsync(fromSequenceNumber, messageCount, sessionId); } else { TRACE_LOGGER.debug("Browsing '{}' messages from entity '{}' from sequence number '{}'", messageCount, this.messageSender.getEntityPath(), fromSequenceNumber); peekFuture = this.messageSender.getInternalSender().peekMessagesAsync(fromSequenceNumber, messageCount);
@Override public CompletableFuture<Void> sendBatchAsync(Collection<? extends IMessage> messages) { return this.sendBatchAsync(messages, TransactionContext.NULL_TXN); }
@Override public CompletableFuture<Void> sendAsync(IMessage message) { return this.sendAsync(message, TransactionContext.NULL_TXN); }
@Override public void cancelScheduledMessage(long sequenceNumber) throws InterruptedException, ServiceBusException { Utils.completeFuture(this.cancelScheduledMessageAsync(sequenceNumber)); }
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); }
@Override public void sendBatch(Collection<? extends IMessage> message) throws InterruptedException, ServiceBusException { Utils.completeFuture(this.sendBatchAsync(message)); }
@Override public void send(IMessage message, TransactionContext transaction) throws InterruptedException, ServiceBusException { Utils.completeFuture(this.sendAsync(message, transaction)); }
/** * Creates a transfer message sender asynchronously. This sender sends message to destination entity via another entity. * * This is mainly to be used when sending messages in a transaction. * When messages need to be sent across entities in a single transaction, this can be used to ensure * all the messages land initially in the same entity/partition for local transactions, and then * let service bus handle transferring the message to the actual destination. * @param messagingFactory messaging factory (which represents a connection) on which sender needs to be created. * @param entityPath path of the final destination of the message. * @param viaEntityPath The initial destination of the message. * @return a CompletableFuture representing the pending creating of IMessageSender instance. */ public static CompletableFuture<IMessageSender> createTransferMessageSenderFromEntityPathAsync(MessagingFactory messagingFactory, String entityPath, String viaEntityPath) { Utils.assertNonNull("messagingFactory", messagingFactory); MessageSender sender = new MessageSender(messagingFactory, viaEntityPath, entityPath, null); return sender.initializeAsync().thenApply((v) -> sender); }
MessageSender mgsSender = new MessageSender(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { mgsSender.sendPost(mgsContent); } return null; } }.execute();
interface MessageListener { void onMessageReceipt(Message message); } class Client implements MessageListener { MessageSender sender; public Client(...) { sender = new Sender(...); } . . . @Override public void onMessageReceipt(Message message) { if(Message.isGood()) sender.send("Congrtulations"); else sender.send("Boooooooo"); } }
@Override public void sendBatch(Collection<? extends IMessage> message, TransactionContext transaction) throws InterruptedException, ServiceBusException { Utils.completeFuture(this.sendBatchAsync(message, transaction)); }
@Override public long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc) throws InterruptedException, ServiceBusException { return Utils.completeFuture(this.scheduleMessageAsync(message, scheduledEnqueueTimeUtc)); }
@Override public long scheduleMessage(IMessage message, Instant scheduledEnqueueTimeUtc, TransactionContext transaction) throws InterruptedException, ServiceBusException { return Utils.completeFuture(this.scheduleMessageAsync(message, scheduledEnqueueTimeUtc, transaction)); }