How to use SessionQualifier to disambiguate otherwise identical session in quickfixj - quickfixj

I have gone through similar question. but this seems different where the sessions can connect to different hosts.
My question is if we have one quickfixj server and one quickfixj client running. Can we have multiple sessions between them?
sample FixClient
#session 1 config
SocketConnectPort=8225
SocketConnectHost=127.0.0.1
SenderCompID=Sender
TargetCompID=Target
SessionQualifier=FirstSession
......
#session 2 config
SocketConnectPort=8226
SocketConnectHost=127.0.0.1
SenderCompID=Sender
TargetCompID=Target
SessionQualifier=SecondSession
Is this even possible?
I have a case where I need to send two types of messages one is a test message and the other is original. Is there a preferred way to distinguish those messages in application code?
[Updated]
When a fix message coming from an quickfixj application say A, which have two sessions A1, A2. and if I need to send messages to Quickfixj application B(in same process which A is running), which then sends to Quickfixj application C(other process). In application C we need to distinguish messages that are coming from A1 and A2. If I make application B to have two session B1, B2 which connects to C1, C2. then when the message comes from A to route to B's sessions. We need to manually store B1,B2 sessionIDs and route accordingly. So here we just want every message that application B gets will simply pass them to C. with some fix tag then we can differentiate test message.

Related

script variable should not be used for call processing?

sir,
I am trying to create stateful proxy in opensips 2.4.
I just wanted a variable to hold received message information and process it.
So i checked "core variable" in opensips manual.it says, script variable are process wise. So i should not use to hold header value in script value like $var(Ruri)=$ru?? it will be overwritten by other call??
$var(userName)=$rU;
$var(removePlus) = '+';
# Search the string starting at 0 index
if($(var(userName){s.index, $var(removePlus)})==0){
$rU=$(var(userName){s.substr,1,0});
}
$var variables are process-local, meaning that you can't share them with other SIP workers even if you wanted to! In fact, they are so optimized that their starting value will often be what the same process left-behind during a previous SIP message processing (tip: you can prove this by running opensips with children = 1 and making two calls).
On the other hand, variables such as $avp are shared between processes, but not in a "dangerous" way that you have to worry about two INVITE retransmissions processing in parallel, each overwriting the other one's $avp, etc. No! That is taken care of under the hood. The "sharing" only means that, for example, during a 200 OK reply processed by a different process than the one which relayed the initial INVITE, you will still be able to read and write to the same $avp which you set during request processing.
Finally, your code seems correct, but it can be greatly simplified:
if ($rU =~ "^+")
strip(1);

Twilio: Responding to user input with multiple distinct messages

I'm working on a twilio-programable-sms chatbot that needs to provide a good chunk of information to a user at the outset of the first conversation. Currently, what we've written is about 562 characters. For some of our users, this gets broken up into chunks of 160 characters that do not necessarily show up in their SMS app in the right order.
To account for this, we're trying to break our message down into 160 character or less distinct messages that each send one-after-the-other.
However, my teammates and I are currently unsure how to accomplish this. Our application is currently written to provide a twiml response for each message that is received from a user. I've been unable to find a way to create a twiml response that indicates a number of consecutive messages, and the theoretical solutions we've come up with feel hacky and flawed.
To demonstrate, currently our code looks like this. As you can see, when a new user sends in the keyword "start" we join 4 messages together in one long text response. However we'd like each message to be sent individually, one after the other, about a second or two apart.
case #body
when "start"
if !!#user
CreateMessage::SubscriptionMessage.triage_subscribable_type(!!#user)
else
[
CreateMessage::AlphaMessage.personalized_welcome(#conversation.from, true),
CreateMessage::SubscriptionMessage.introduce_bcd,
CreateMessage::SubscriptionMessage.for_example,
CreateMessage::SubscriptionMessage.intvite_to_start
].join("\n\n")
end
We'd like to avoid creating a background worker/cron job, if possible - but welcome any and all suggested solutions.
I think your question is more on how to design synchronous(webhook response) vs asynchronous responses/messages. I have not used twiml but the concepts are same.
If you don't want to use a background job, then send fir N-1 messages using API with time delay in between, and the last message as response.
If you are OK with using background jobs, then send 1st message as response and queue a job for sending the remaining messages using API.

Copying a list of subscribed data in System center orchestrator

I'm using System Center Orchestrator 2012, and I have a generic error handler which is connected to all the activities in my runbook.
I have subscribed to a list of published data as a parameter in this error handler, which looks like this:
Activity Name : {Activity Name from "Monitor File"}{Activity Name from "Move file"}.......
What I need to do is copy this list of subscribed data and do a search and replace to change the Activity Name parameter to something else, say Error Message. Whenever I copy this list of variables, I get gibberish when I paste it
\`d.T.~Ed/{598EBDFA-BF5B-4B77-8156-E6FA6ECD0CE1}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{6838D741-DF8E-4C25-8C28-D06A52F67D36}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{D1D9BBE6-5AAF-4D8F-A98A-1A8BDD977E7E}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{9EC92323-1B9B-4D06-88E9-A97BA525CF5A}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{FAD32B4C-92CC-40BD-837A-4C5F22C2E018}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{DFF7A110-ACFD-4377-AFEC-16B5BEC8BFF4}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{139ACC4E-CF6D-4EEE-BD88-9DC1E0FC2038}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{1484789C-BB37-4507-AD21-E367665E0BE6}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{01EA8BD0-69C5-4959-86DB-29FAD34D144A}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{A60C582B-5DD0-41F7-BB0A-B5D71C3B9ECB}.Object.Name\`d.T.~Ed/\`d.T.~Ed/{1FA1E2D6-813D-4A4A-A5CD-07EB2AD4AC9B}.Object.Name\`d.T.~Ed/
Is there a way to simply copy the text? If not, I will have to click on all the activities over and over again to subscribe to different types of data.
Thanks in advance
The gibberish you're seeing is how Orchestrator translates the published data and variables to the database guids. Copying this out will always translate to the DB guids, so there's no way to do a copy/replace with "activity name" for "Error Summary". You'd need to subscribe to each activity's data or look up all of the guids which probably wouldn't be easier.
Unfortunately, setting up the error handling process in SCOrch becomes tedious to be effective.
I use a separate email linked to each activity to give more information based on the error message. I don't like to use generic error emails with published data from multiple activities since it doesn't necessarily give all the useful information you need (or an end user will be able to understand).

Is there a way to create a circular file storage ? like syslog in linux

In my iOS application, I want to store some messages that I obtain from my remote server. However, instead of storing these messages forever, I want to purge, once I have a N number of messages; i.e., if my N is configured to be 10, I want to store 10 messages and on the arrival of the 11th message, I want to delete the 1st message.
Is there a standard way to do this in iOS ? I am yet to write the code to saving the messages, so choosing any method of saving is fine for me.
Store your messages in a file. After you get the message read your file's messages to an NSMutableArray, replace the most old message with new one and overwrite your file with new array data.
I dont think there is a straight fwd way.
The way I would do is have a table using SQLLite. Have 2 columns id(int, autoincrement), value(String). When inserting, if max(id) >=10 delete row with min(id) and insert the new value.
Ofcourse, this woud fail after it reached MAX_INT_VALUE. So if you thing you would never get to this value you are good.

Broadcasting to a subset of subscribers in Atmosphere

What I'm trying to do:
Be able to have users subscribed to a number of different 'chat rooms' and use reverse AJAX / comet to send messages from a chat room to everyone logged into that room. (a bit more complicated but this is a similar use case).
What I'm doing:
Using Grails with JMS and Atmosphere. When a message is sent, I'm using JMS to send the message object which is received by a Grails service which is then broadcasted to the atmosphere URL (i.e. atmosphere/messages).
Obviously JMS is a bit redundant there but I though I could use it to help me filter who should retrieve the message although that doesn't really look it'll work (given that the subscriber is basically a singleton service...).
Anyway, what I need to be able to do is only send out a message to the correct subset of people listening to atmosphere/messages. A RESTful-type URL will be perfect here (i.e. atmosphere/messages/* where * is the room ID) however I have no idea how to do that with Atmosphere.
Any ideas / suggestions on how I can achieve what I want? Nothing is concrete at all here so feel free to suggest almost anything. I've even been thinking (based on the response to another question), for example, if I could do something like send out messages to a Node.js server and have that handle the reverse AJAX / comet part.
If I understand your requirements correctly the following should work (jax-rs + scala code):
1) Everyone who wants to get messages from a chat room registers for it:
#GET
#Path(choose/a/path)
def register(#QueryParam("chatroomId") chatroomId: Broadcaster) {
// alternatively, the Suspend annotation can be used
new SuspendResponse.SuspendResponseBuilder[String]()
.resumeOnBroadcast(false).broadcaster(chatroomId).scope(SCOPE.REQUEST)
.period(suspendTimeout, TimeUnit.MINUTES)
.addListener(new AtmosphereEventsLogger()).build
}
2) To broadcast a message for all the registered users, call the following method:
#POST
#Broadcast
#Path(choose/a/path/{chatroomId})
def broadcast(#PathParam("chatroomId") id: String) {
// first find your broadcaster with the BroadcasterFactory
BroadcasterFactory.getDefault().lookupAll() // or maybe there is a find by id?
broadcaster = ...
broadcaster.broadcast(<your message>)
}
I also recommend reading the atmosphere whitepaper, have a look at the mailing list and at Jeanfrancois Arcand's blog.
Hope that helps.
There is a misunderstaning of the concept of comet. Its just another publish/subscribe implementation. If you have multiple chat-rooms, then you need to have multiple "topics", i.e. multiple channels the user can register to. E.g.:
broadcaster['/atmosphere/chatRoom1'].broadcast('Hello world!')
broadcaster['/atmosphere/chatRoom2'].broadcast('Hello world!')
So I would advance you to creaet multiple channels and do not filter manually the set of users, which should retrieve messages (which is definitely not the way it should be done). You do not need to create anything on the server side on this, since the user will just register for a specific channel and receive messages, which anyone is putting into it.
I would recommend you create an AtmosphereHandler for one URL like /atmosphere/chat-room and then use the AtmosphereResource and bind an BroadcastFilter with it, lets say name it ChatRoomBroadcastFilter.
Whenever a user subscribes to a new chat room, a message would be sent to the server (from the client) telling the server about the subscription. Once subscribed, maintain the list of users <> chat room bindings somewhere on the server.
Whenever a message is broadcasted, broadcast it with the chat room id with it. The in the ChatRoomBroadcastFilter (You probably need to make this a PerRequestBroacastFilter) propagate the message to the user only if the user subscribed to the chat room. I am not sure if this clears it out. If you need code example please mention in the comments. I'll put that but that needs some time so ain't putting it right now ;).

Resources