I want to pass some message between two communicating channels in call, My requirement is two java applications will act as two different users in a call, There should be some message that can be shared only between two channels in specific call, so that if one application is going to play something it can send message saying that you record now and vice-verse. I will be thankful if somebody can help me out.
You can use AMI to watch for UserA trying to share data, and then set it on UserB's channel.
Background to this...
Sounds like a similar problem that I had. With two users in a call, I wanted user A to start recording the call. I wanted the recording to start on User B's channel so that if the call was transfer, that channel was not destroyed and the recording would continue. Simply calling MixMonitor starts the recording on the channel that calls MixMonitor which would be UserA's channel.
I wrote a small application that monitors UserA and listens for a UserEvent from UserA (see 'core show application UserEvent') and then start Mixmonitor on UserB's channel. It also has to keep track of channels so that it knows which channel belongs to UserB.
Related
My programme is a notification service, it basically receives http requests(client sends notifications) and forwards them to a device.
I want it to work the following way:
receive client notification request
save it to the database(yes, i need this step, its mandatory)
async threads watch new requests in database
async threads forward them to the destination(device).
In this case the programme can send client confirmation straight away after the step 2).
Thus, not waiting for the destination to respond(device response time can be too long).
If I stored client notification in memory i would use BlockingQueue. But I need to persist my notifications in db. Also, I cannot use Message Queues, because clients want rest endpoints to send notifications.
Help me to work out the architecture of such a mechanism.
PS In Java, Postgresql
Here are some ideas that can lead to the solution:
Probably the step 2 is mandatory to make sure that the request is persisted so that rather it will be queried. So we're talking about some "data model" here.
With this in mind, if you "send" the confirmation "right away after the step 2" - what if later you want to do some action with this data (say, send it somewhere) and this action doesn't succeed. You store it on disk? what happens if the disk is full?
The most important question is what happens to your data model (in the database) in this case? Should the entry in the database still be there or the whole "logical" action has failed? This is something you should figure out depending on the actual system the answers can be different.
The most "strict" solution would use transactions in the following (schematic) way:
tr = openTransaction()
try {
saveRequestIntoDB(data);
forwardToDestination(data);
tr.commit();
} catch(SomeException ex) {
tr.rollback();
}
With this design, if something goes wrong during the "saveRequest" step - well, nothing will happen. If the data is stored in db, but then forwardToDestination fails - then the transaction will be rolled back and the record won't be stored in DB.
If all the operations succeed - the transaction will be committed.
Now It looks like you still can use the messaging system in step 4. Sending message can be fast and won't add any significant overhead to the whole request.
On the other hand, the benefits are obvious:
- Who listens to these "notifications"? If you send something and only one service should receive and process the notification how do you make sure that others won't get it? How would you implement the opposite - what if all the services should get the notification and process it independently?
These facilities are already implemented by any descent messaging system.
I can't really understand the statement:
I cannot use Message Queues, because clients want rest endpoints to send notifications.
Since the whole flow is originated by the client's request I don't see any contradication here. The code that is called from rest endpoint (which is after all is a logic entrypoint that should be implemented by you) can call the database, persist the data and then send the notification...
I'm using Agora.io to create video chat between two people. On server side, I have recorder plugin that is used to record all chats between users.
My question is can I get notified some how (or create some listener) when channel is created so I will start recording? I need to get such notification from agora server and not from client if possible
Thanks
Implementing the recording really depends on how you want to implement it. Channels (within the Agora.io platform) don't have a "ready" state. Once a user joins the channel, the channel now exists, first user to join the channel is a broadcaster (unless explicitly set as a viewer prior to joining a broadcast channel)
Regardless of the logic you choose to implement, with all of the Agora.io SDKs there is a callback event for when the local user has joined the channel and one whenever a remote user joins a channel, so you decide when to programmatically call the recording server.
I want to implement push notification in java so please help me out
1-Each time a new record(Message) pushed into data base(due to event created by some other user), a push notification should be sent to specific Logged in user automatically.
2-Content of the push notification should be the message present in the db.
3-If there are multiple messages, then the user should receive them one by one in a queue fashion.
4-Most important thing is the logged in user need not have to trigger any event to get notification, user should receive it automatically throughout the session.
You could use Server Sent Events. Java provides SseEmitter to send timely notifications.
You can use EventSource API in JavaScript to trigger the SSE event stream and in the server-side, loop the database query code which is wrapped by an ExecutorService - which can spin of separate thread based on the initialization.
Put SSE timeout to -1 for listening for an infinite amount of time.
Please note this answer is only a hint. Use these to explore more from the internet.
I am developing a small real-time application to record sound waves. It has two modules: recording , listening.
here is how it should work :
The program starts listening.
A sound wave arrives.
The program recognizes that a signal has arrived, and starts
recording it.
When the signal is over (no more loud sounds), the program stops
recording and saves the result to a file.
So in order to recognize when the signal is over - we should listen to the wave (capture) along with recording, so we can detect when the sound is over.
In order to implement this, iv'e used the Java sound API, but i have one problem:
The target-data-line object is shared between the recording-thread and the capture-thread. In this case, two threads are working on the same target-data-line : The capture and the recorder threads.
which cases some real-time problems.
I have tried to open two target-data-lines, one for recording and one for capturing , but the program throws an exception when trying to open the second one.
How can i fix the problem ?
please help.
You need to use a single thread which has exclusive access to the TargetDataLine. This thread can then generate events which your recording and listening thread can subscribe to.
I am developing a testing application on an Architecture which is based on Producer-Consumer structure. I have an producer-consumer* problem, especially if an producer callback mechanism is utilized in android service i.e. consumer. Consumers are not supposed to hold the call for more than the minimum necessary time to have the info handed over. Since the producer’s callbacks are supposed to run in a different thread than the consumer’s one.
In my specific case within the callback of Producer only a reference moving of the passed object should be done and release the control right away. The object has to be consumed in the consumer thread. Currently I have been calling a method which only gets data coming within callback and processes that data and return it via Intent baack to the Android Activity.
Now, Android intents are well known to be resource consuming entities which are not meant (and not supposed) to be used to transfer data streams.
Within the Test app, one intent per callback is generated. Those overflow the whole system. For example, at 25% of load a traffic of about a thousand Android intents per seconds are triggered.
I want a way which doesn't include Android Intents(without any Thrid party jar) using which I can send data back to my android activity or route on host machine at super high rate so that my producer call back doesn't get crashed.
Use a socket connection between the Service and the Activity for streaming data. Intent is the wrong technique.