i'm working currently on a openfire server where i have different user and 4 possible subcriptions topics. now i want to show topics which are subscribed on the start of the client.
Is there a way to search for subscriptions a user have via Smac (xmpp) ?
You should be able to use the PubSubManager (<- Smack api doc link) to get all the subscriptions and nodes. Below uses PubSubManager to get a list of subscriptions and then use that list to get all the subscription ids:
try
{
PubSubManager manager = new PubSubManager(XMPPClient.connection);
List<Subscription> listSubs = manager.getSubscriptions();
for(int i = 0; i < listSubs.size(); i++)
{
System.out.println(listSubs.get(i).getId());
}
}
catch(XMPPException e)
{
System.out.println(e.getMessage());
}
Simple example to print all ids of subscriptions that connection is subscribed to. XMPPClient is the name of your Smack XMPPClient instance. However, if you need the nodes and specific node information you can get the nodes from the ids using the manager and then get node info using the Node class. Check that documentation, you can get pretty much everything you need about the subscription nodes with that.
Hope that helps!
Related
I need to make REST requests to Tableau to upload and download data sources and other requests.
In the documentation mentioned here, it says that to make a REST request you need.
Server Name
SiteID
Workspace/Group ID
Where can I get these 3 things? I am new thus not familiar with the tableau platform.
Below is my Tableau Dashboard:
I see you've figured this out based on some of your other questions but here is the answer for anyone else searching.
Server name = your server's ip address or if using Tableau Online, the first portion of your url when you login.
10ay.online.tableau.com for the GET call of
https://10ay.online.tableau.com/api/3.12/sites/site-id/projects/project-id
Site ID can be returned using a POST in your API authentication call. Using the server name above the POST call would look like this https://10ay.online.tableau.com/api/3.4/auth/signin You will need to add some info to the POST body that will look like this.
{
"credentials": {
"personalAccessTokenName": "YOURTOKENNAME",
"personalAccessTokenSecret": "YOURTOKENSECRET",
"site": {
"contentUrl": "YOURSITE"
}
}
}
You don't necessarily need the group-id unless you are returning group specific info like user/group relationships. Use this in a GET call to return your group IDs by name. https://10ay.online.tableau.com/api/3.12/sites/site-id/groups
This is still a theory in my mind.
I'm rebuilding my backend by splitting things into microservices. The microservices I'm imagining for starting off are:
- Order (stores order details and status of each order)
- Customer (stores customer details, addresses, orders booked)
- Service Provider (stores service provider details, status & location of each service provider, order(s) currently being processed by the service provider, etc.)
- Payment (stores payment info for each order)
- Channel (communicates with customers via email / SMS / mobile push)
I hope to be able to use PUB/SUB to create a message with corresponding data, which can be used by any other microservice subscribing to that message.
First off, I understand the concept that each microservice should have complete code & data isolation (thus, on different instances / VMs); and that all microservices should communicate strictly using HTTP REST API contracts.
My doubts are as follows:
To show a list of orders, I'll be using the Order DB to get all orders. In each Order document (I'll be using MongoDB for storage), I'll be having a customer_id Foreign Key. Now the issue of resolving customer_name by using customer_id.
If I need to show 100 orders on the page and go with the assumption that each order has a unique customer_id associated with it, then will I need to do a REST API call 100 times so as to get the names of all the 100 customer_ids?
Or, is data replication a good solution for this problem?
I am envisioning something like this w.r.t. PUB/SUB: The business center personnel mark an order as assigned & select the service provider to allot to that order. This creates a message on the cross-server PUB/SUB channel.
Then, the Channel microservice (which is on a totally different instance / VM) captures this message & sends a Push message & SMS to the service provider's device using the data within the message's contents.
Is this possible at all?
UPDATE TO QUESTION 2: I want the Order microservice to be completely independent of any other microservices that will be built upon / side-by-side it. Channel microservice is an example of a microservice that depends upon events taking place within Order microservice.
Also, please guide me as to what all technologies / libraries to use.
What I'll be developing on:
Java
MongoDB
Amazon AWS instances for each microservice.
Would appreciate anyone's help on this.
Thanks!
#1
If I need to show 100 orders and each order has a unique customer_id, will I need to do 100 REST API call?
No, just make 1 request with 100 order_id(s) and return a dictionary of order_id <=> customer_id
#2
It's a single request
POST
/orders/new
{
"selected_service_provider_id" : "123"
...
}
Which can return you order_id and you can print it locally for the customer or track progress or what have you.
On the server side, you receive an order and process it. Processing can include sending an SMS at some stage. This functionality can be implemented inside original service that received this request or as a separate call to another dedicated service.
To your first question, you don't need to do 100 queries, just one with the array of your 100 documents, like the following:
db.collection.find( { _id : { $in : [1,2,3,4] } } );
https://stackoverflow.com/a/7713461/1384539
I know this question is 1 year old, but I would like to add my answer to the first point.
One option would be to use some form of CQRS and store on the OrderDB also some of the user details when creating an order. This way when you have to show the list of orders you already have all the details you need. Also, the order document would represent a photograph of the user state at the moment of the order creation.
Of course, in case you don't have the user details when storing the order, you just need to make a GET call to the User Service, but that would be 1 call, not 100.
I'm currently implementing a simple chat in order to learn how to use deepstream.io. Is there an easy way to get an interval from, lets say, a list of records? Imagine the scenario that a user wants to get old chat messages by scrolling back in the history. I could not find anything about this in the documentation, and I have read through the source with no luck.
Is my best bet to work against a database (e.g. RethinkDb) directly or is there an easy way to do it through deepstream?
First: The bad news:
deepstream.io is purely a messaging server - it doesn't look into the data that passes through it. This means that any kind of querying functionality would need to be provided by another system, e.g. a client connected to RethinkDB.
Having said that: There's good news:
We're also looking into adding chat functionality (including extensive history keeping and searching) into our application.
Since chat messages are immutable (won't change once they are send) we will use deepstream events, rather than records. In order to facilitate chat history keeping, we’ll create a "chat history provider", a node process that sits between deepstream and our database and listens for any event that starts with 'chat-'. (Assuming your chat events are named
chat-<chat-name>/<message-id>, e.g. chat-idle-banter/254kbsdf-5mb2soodnv)
On a very high level our chat-history-provider will look like this:
ds.event.listen( /chat-*/, function( chatName, messageData ) {
//Add the timestamp on the server-side, otherwise people
//can change the order of messages by changing their system clock
messageData.timestamp = Date.now();
rethinkdbConnector.set( chatName, messageData );
});
ds.rpc.provide( 'get-chat-history', function( data, response ){
//Query your database here
});
Currently deepstream only supports "listening" for records, but the upcoming version will offer the same kind of functionality for events and rpcs.
I feel like this has got to be obvious, but I've been searching and just can't find the answer.
I'm programming a 'bot' which connects to my twitch channel's chat. I'd like to track the number of consecutive streams watched by users. I have a command that I type at the start of each stream to signify that a new stream has started, and so, users who join should have their number of consecutive watched streams increased.
I currently use the JOIN event to increase the users consecutive streams count, but if someone is sitting in chat before the start of the stream, they don't get credit because the JOIN event happened before the flag that a new stream has started has been set.
Is there any way to get a list of the current $nick's in the chat? If so, I could hook that into the command when I start the stream and update the users who are already in chat.
You can use $nick(#,N) to retrieve the number of users in a channel, where # is the name of your channel and N is a number.
You should first use $nick(#mychannel,0) to get the total amount of users in your channel and then you can loop with that number through the users list also with $nick(#,N).
For example, you do //echo $nick(#mychannel,0) it will say 10. When you use $nick(#mychannel,1) it will return the first user in the user list.
Simple code example:
alias getusers {
var %users = $nick($1,0), %n = 1
while (%n <= %users) {
; print all users in the channel
echo -ag $nick($1,%n)
; you can put your code here
inc %n
}
}
Type /getusers #channelname in a channel to get a list of all users.
Tell me if you need more help.
Is there any predefined method in XMPP to get the number of rooms already present on the openfire server. I have made a thorough search but I am unable to get the good and working answer.
Please let me know how can I get the rooms available on openfire server ( already created ).
The code
boolean supports = MultiUserChat.isServiceEnabled(conn, "user3#host.org/Smack");
is returning a NUll pointer.
You can use getHostedRooms method of MultiUserChat class of Smack API.
public static Collection<HostedRoom> getHostedRooms(Connection
connection, String serviceName) throws XMPPException
This will return collection of all public rooms on server. And before this check if user supports MUC or not by
boolean supports = MultiUserChat.isServiceEnabled(conn, "user3#host.org/Smack");
More information on this can be found on smack api guide.