Can I create a new conference room (Asterisk ConfBridge) through AMI? - asterisk

Can I create a new conference room (Asterisk ConfBridge) through Asterisk Manager Interface (AMI)? Help me please!

This response is for anyone who has struggled as me to do this, even if the first response and the comments to it may be enough.
So, you can originate a conference call, with the action Originate and the application ConfBridge (as far as i know, it comes with Asterisk, not independent).
You can see all the available fields here http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Originate
I will throw an example without every field, but the ones I know and needed on my app.
This is what you throw at the Asterisk Manager Interface, if you want to call someone into a conference, then add someone else (without the comments ofc.)
Action: Originate // The action type
ActionID: CreateConf-1 // This id will be linked to further events about the action
Channel: SIP/1001 // The sipId of the peer u wanna call
Timeout: 30000 // If he doesnt respons in 30000ms, drop it
CallerID: Asterisk // The id of the caller (will be seen on target phone)
Application: ConfBridge // The application
Async: true // (NOT SURE, MAYBE BULLSHIT) If false, i think you can no longer originate while he hasn't answered
Data: 1234 // Very important, this is like the conference id, will detail above
Action: Originate
ActionID: CreateConf
Channel: SIP/1000
Timeout: 30000
CallerID: Asterisk
Application: ConfBridge
Async: true
Data: 1234
So with this, one block at time, two guys will be called into a conference.
As you saw the Data field represents the identifier of the call, so if you wanna give your conference an id, use it. This way you could create and manage different conferences.
Since i work with NAMI (the nodejs library for Asterisk Manager Interface) (https://github.com/marcelog/Nami), let me also drop you how to do thanks to the lib.
var namiLib = require('nami');
var namiInstance = new (namiLib.Nami)(config); // See more about config (and everything else about nami) in their docs
namiInstance.open();
var action = new namiLib.Actions.Originate();
action.channel = 'SIP/1000';
action.data = '12345'; // my conferenceId
action.timeout = 30000;
action.callerID = 'Metisse\'s king';
action.application = 'ConfBridge';
action.async = true;
namiInstance.send(action, function (response) {
// deal with the response
});
Obviously, if you need to use NAMI to have control other Asterisk, you have to do something more generic to handle sending your actions and validating them, also watching for errors.

You can use dynamic conference(without room exist) feature and create calls using Originate command to application Confbridge.

No. You can use an AMI redirect to transfer your call to a piece of dialplan code that would read a channel variable, database look up or some other mechanism to set up a new conference, however.
For a full list of AMI actions for ConfBridge, please see: https://wiki.asterisk.org/wiki/display/AST/ConfBridge+10#ConfBridge10-ConfBridgeAsteriskManagerInterface(AMI)Actions

Related

Axon Partialy replay, how do i get a TrackingToken for the startPosition for the replay?

I want my Axon replay events, not all but partially.
A full replay is up and running but when i want a partially replay i need a TrackingToken startPosition for the method resetTokens(), my problem is how to get this token for the partial replay?
I tried with GapAwareTracingToken but this does not work.
public void resetTokensWithRestartIndexFor(String trackingEventProcessorName, Long restartIndex) {
eventProcessingConfiguration
.eventProcessorByProcessingGroup(trackingEventProcessorName, TrackingEventProcessor.class)
.filter(trackingEventProcessor -> !trackingEventProcessor.isReplaying())
.ifPresent(trackingEventProcessor -> {
// shutdown this streaming processor
trackingEventProcessor.shutDown();
// reset the tokens to prepare the processor with start index for replay
trackingEventProcessor.resetTokens(GapAwareTrackingToken.newInstance(restartIndex - 1, Collections.emptySortedSet()));
// start the processor to initiate the replay
trackingEventProcessor.start();
});
}
When i use the GapAwareTrackingToken then i get the exception:
[] - Resolved [java.lang.IllegalArgumentException: Incompatible token type provided.]
I see that there is also a GlobalSequenceTrackingToken i can use, but i don't see any documentatieon about when these can/should be used.
The main "challenge" when doing a partial reset, is that you need to be able to tell where to reset to. In Axon, the position in a stream is defined with a TrackingToken.
The source that you read from will provide you with such a token with each event that it provides. However, when you're doing a reset, you probably didn't store the relevant token while you were consuming those events.
You can also create tokens using any StreamableMessageSource. Generally, this is your Event Store, but if you read from other sources, it could be something else, too.
The StreamableMessageSource provides 4 methods to create a token:
createHeadToken - the position at the most recent edge of the stream, where only new events will be read
createTailToken - the position at the very beginning of the stream, allowing you to replay all events.
createTokenAt(Instant) - the most recent position in the stream that will return all events created on or after the given Instant. Note that some events may still have a timestamp earlier than this timestamp, as event creation and event storage isn't guaranteed to be the same.
createTokenSince(Duration) - similar to createTokenAt, but accepting an amount of time to go back.
So in your case, createTokenAt should do the trick.

Nats which pattern to use

I asked a question in:
Microservice Architecture dependency which pattern to use when using a clustered Microservice architecure.
I recieved answer that point to point should work but when reading:
https://nats.io/documentation/concepts/nats-req-rep/
It feels like all subscribers recieves event (and because of that handles it) but there will just be one subscriber that responses. This will not work when putting an order event that will trigger an update-inventory-event that Inventory microservices subscribes to (as in example in link) i.e it wont work in a clustered env due to inventory will be updated the same amount of times as the amount of microservice instances.
How can I solve this scenario using Nats?
Thanks in advance!
NATS.io supports this feature using queue groups:
All subscriptions with the same queue name will form a queue group.
Each message will be delivered to only one subscriber per queue group,
using queuing semantics. You can have as many queue groups as you wish.
Normal subscribers will continue to work as expected.
Connect your services using the queue group (sample is node.js):
https://github.com/nats-io/node-nats#queue-groups
nats.subscribe('foo', {'queue':'job.workers'}, function() {
received += 1;
});
then the client would use the library provided request methods:
https://github.com/nats-io/node-nats#basic-usage
// Request for single response with timeout.
nats.requestOne('help', null, {}, 1000, function(response) {
// `NATS` is the library.
if(response.code && response.code === NATS.REQ_TIMEOUT) {
console.log('Request for help timed out.');
return;
}
console.log('Got a response for help: ' + response);
});

Efficient pattern for updating a subscription limit argument

I'm using subs-manager, but the answer to this may be independent of that lib.
I have a subscription with a single limit argument. Currently, when I call subs.subscribe 'subname', newLimit, another subscription is added.
The old subscriptions are still there. I don't want Meteor to spend time maintaining the old, lower-limit subscriptions. Instead of adding a new subscription, I want to update the argument of the old subscription. What is the best way to do this?
Note that I also don't want to completely tear down eg 'subname', 20 before subscribing to 'subname', 40, because I don't want Meteor to do the extra work of resending the first 20 docs – I want it to just send docs 21 - 40.
You could have a look at your subscription's stop() method. According to the docs:
stop() [cancels] the subscription. This will typically result in the server directing the client to remove the subscription's data from the client's cache.
So the way I see it, you could maybe manage to do:
// globals or whatever
var previousSub, newSub;
// somewhere else
newSub = Meteor.subscribe('subname', newLimit, function () {
if (previousSub)
previousSub.stop();
previousSub = newSub;
});

When is the "null" publish ready?

Having the following code on the server:
Meteor.publish(null, function(){
// Return some cursors.
})
will according to the documentation have the following effect: the record set is automatically sent to all connected clients.
How can I on the client side determine if all the documents published by this function has been received? If I would use a subscription instead, it would provide me with a ready callback, letting me know when all the documents been received. What's the matching way here? Or are the documents already received at the client when my client side code starts to execute?
I'm afraid there's no way to have a ready callback for so called universal subscriptions you mentioned above. Just have a look at this part of Meteor's code, where the publish and subscription logic is defined on the server. For convenience I'm copy/pasting the code below:
ready: function () {
var self = this;
if (self._isDeactivated())
return;
if (!self._subscriptionId)
return; // unnecessary but ignored for universal sub
if (!self._ready) {
self._session.sendReady([self._subscriptionId]);
self._ready = true;
}
}
The _subscriptionId is only given to named subscriptions, which are those that you would manually define using Meteor.subscribe method. The subscriptions corresponding to null publish functions, doesn't have their own _subscriptionId, so as you can see from the code above, the server is not event trying to send the ready message to the client.

SignalR: connect to one hub from javascript, not to all of them

The following connects the js client to all the existent hubs:
$.connection.hub.start({ transport: 'longPolling' }).done(function () {});
Is there some way to connect to some particular hub instead?
If not, what is the point of "OnConnected()" and "OnDisconnected()" being in EVERY hub? if all of them are going to be called anyway.
I'm asking this because there is a particular html (something like a news feed) in which I want to handle notifications from one hub (when news are posted, this view should handle and show them appearing). I'm going to use groups but seems more natural to separate this in hubs.
You only subscribe to hubs that you have client side events associated with. So lets say you had two hubs:
hubA
hubB
In your client if you have:
var hubA = $.connection.hubA;
hubA.client.foo = function() {};
$.connection.hub.start();
You will only be subscribed to events on hubA (not hubB).
You can choose to use or not use the connection events in any hubs you create. You certainly can separate your code into logical sections using hubs, no harm in that.
var connection = $.hubConnection(server);
var someHub= connection.createHubProxy("someHub");
connection.start({transport: 'longPolling'}).done(function () {})

Resources