web stats
Is it possible to implement a Mirth consumer? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-19-2014, 03:45 AM
ab2488587 ab2488587 is offline
OBX.1 Kenobi
 
Join Date: Nov 2014
Posts: 32
ab2488587 is on a distinguished road
Question Is it possible to implement a Mirth consumer?

I'm trying to make Mirth a message broker in the following sense:

Mirth should conditionally either broadcast messages to all devices, a specific device or group of devices.
Devices who will be receiving messages can be offline sometimes.
Messages are Queued in Mirth.
When the device regains connection and authenticates with Mirth, he receives unread (queued) messages.

I'm thinking of registering every device and its group in a DB.
One channel writes messages to DB.
Another listens for devices, SELECTing unread messages for the requesting device from the DB and then sends them.

Is this the only/simplest way of doing this?
Do I have better alternatives?
Reply With Quote
  #2  
Old 12-19-2014, 04:08 AM
ab2488587 ab2488587 is offline
OBX.1 Kenobi
 
Join Date: Nov 2014
Posts: 32
ab2488587 is on a distinguished road
Default

Another solution I thought up was:
Pushing incoming messages into a queue of a dummy destination and then the listening channel pops them accordingly, is this possible and/or an alternative?

I realize that this should be a job for a *MQ but I'm trying to replace an existing *MQ and consolidating everything in Mirth.
Reply With Quote
  #3  
Old 12-19-2014, 07:12 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,101
narupley is on a distinguished road
Default

Since channels/connectors/transformers themselves are meant to be largely stateless (take in a message, process it, send it out), it makes sense to store that consumer-specific data elsewhere, like in an RDBMS table. You could just have a separate destination (with it's own queue) for each consumer, so that when it comes online MC would automatically start sending to it. But that does not scale well to an arbitrarily large amount of consumers. With a separated data store, you'll be able to more easily handle new consumers, etc.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #4  
Old 12-19-2014, 07:32 AM
ab2488587 ab2488587 is offline
OBX.1 Kenobi
 
Join Date: Nov 2014
Posts: 32
ab2488587 is on a distinguished road
Default

Quote:
Originally Posted by narupley View Post
You could just have a separate destination (with it's own queue) for each consumer, so that when it comes online MC would automatically start sending to it. But that does not scale well to an arbitrarily large amount of consumers. With a separated data store, you'll be able to more easily handle new consumers, etc.
Like you said, not scalable.
Quote:
Originally Posted by narupley View Post
[...], it makes sense to store that consumer-specific data elsewhere, like in an RDBMS table.
Any chance I could keep that consumer-specific data in Mirth's internal DB?
And create a channel to make CRUD operations to that table?

"Want a new device? Sure! Send message to Mirth @ XYZ adress. Bam. Created."
Reply With Quote
  #5  
Old 12-19-2014, 07:33 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,101
narupley is on a distinguished road
Default

Quote:
Originally Posted by ab2488587 View Post
Like you said, not scalable.


Any chance I could keep that consumer-specific data in Mirth's internal DB?
And create a channel to make CRUD operations to that table?

"Want a new device? Sure! Send message to Mirth @ XYZ adress. Bam. Created."
The same database server, sure. I would recommend creating a separate schema though, instead of touching mirthdb.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #6  
Old 12-19-2014, 07:57 AM
ab2488587 ab2488587 is offline
OBX.1 Kenobi
 
Join Date: Nov 2014
Posts: 32
ab2488587 is on a distinguished road
Default

Quote:
Originally Posted by narupley View Post
The same database server, sure. I would recommend creating a separate schema though, instead of touching mirthdb.
Noted. Thank you.

Just curious but is it possible to dynamically add destinations to a channel?
Without stopping it?
i.e. Channel A receives requests to add a device destination to channel B.

This would require URLs to devices which I guess is not possible in my case, they wouldn't have static addresses, in most cases.

Last edited by ab2488587; 12-19-2014 at 07:58 AM. Reason: Typo
Reply With Quote
  #7  
Old 12-19-2014, 08:10 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,101
narupley is on a distinguished road
Default

Quote:
Originally Posted by ab2488587 View Post
Noted. Thank you.

Just curious but is it possible to dynamically add destinations to a channel?
Without stopping it?
i.e. Channel A receives requests to add a device destination to channel B.

This would require URLs to devices which I guess is not possible in my case, they wouldn't have static addresses, in most cases.
That is not possible, no. However you can use variables in your destination settings to dynamically send to different places for each message.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Tags
broadcast, consumer, message broker, queue

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:14 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation