web stats
Disable channel Destination at runtime? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2012, 02:10 AM
shravan.cv@gmail.com shravan.cv@gmail.com is offline
What's HL7?
 
Join Date: Jul 2009
Posts: 3
shravan.cv@gmail.com is on a distinguished road
Default Disable channel Destination at runtime?

Hi,

Can it be Possible to Disable one of the channel Destination at runtime?
Reply With Quote
  #2  
Old 02-22-2012, 11:49 AM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 461
upstart33 is on a distinguished road
Default

I never tried it, but I believe it may be possible via something like:

Code:
Packages.com.webreach.mirth.server.controllers.ChannelStatusController.getInstance().stopChannel(channelId);

Your available methods are: stopChannel, startChannel, pauseChannel, resumeChannel. Each takes the channel ID as a parameter (not the the channel name).
Reply With Quote
  #3  
Old 03-01-2012, 05:55 AM
dash4_11 dash4_11 is offline
What's HL7?
 
Join Date: Sep 2011
Posts: 4
dash4_11 is on a distinguished road
Default

Disable Channel Destination or Channel it self ??
Reply With Quote
  #4  
Old 03-01-2012, 06:03 AM
upstart33 upstart33 is offline
Mirth Guru
 
Join Date: Dec 2010
Location: Chicago, IL.
Posts: 461
upstart33 is on a distinguished road
Default

Oops. My fault. I posted code relating to stopping the Channel itself, not the destination.
Reply With Quote
  #5  
Old 03-01-2012, 06:08 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Using a DefaultChannelController you should be able to do this; you can get the connectors from a Channel with getSourceConnector or getDestinationConnectors. From there, the Connector.setEnabled will do the trick. However, you will still have to re-deploy the channel for it to take effect, but you can set a flag and then do this conditionally in the postprocessor with a core.Client instance.
Reply With Quote
  #6  
Old 03-01-2012, 06:30 AM
dash4_11 dash4_11 is offline
What's HL7?
 
Join Date: Sep 2011
Posts: 4
dash4_11 is on a distinguished road
Default i did this in transformer

don't know if it helps

if(Every thing correct)
{
globalmap.put("DESTIP","10.10.1.1") ;
globalmap.put("PORT",1234) ;
}
else
{
//send mail and
globalmap.put("DESTIP","0.0.0.0")
globalmap.put("PORT",0000)

}
Reply With Quote
  #7  
Old 03-01-2012, 08:11 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 321
StefanScholte is on a distinguished road
Default

@Narupley

How do you use a DefaultChannelController?
Reply With Quote
  #8  
Old 03-01-2012, 09:32 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

You can create one with "new com.mirth.connect.server.controllers.DefaultChanne lController.create()". From there, you can get your channel by ID, get the list of connectors, and find the specific connector you want to disable. I think Mirth already prevents this anyway, but it might be smart to do some validation to make sure that you're not disabling the only currently enabled destination. Once that's done, use the same ChannelController to update the channel with your ServerEventContext (or just use the system context; it's up to you).

Everything you need is here!

EDIT: Interesting, it seems that Mirth actually doesn't automatically do that sort of validation, so it is possible for you do manually disable all the destinations of a channel. FYI...

Last edited by narupley; 03-01-2012 at 09:37 AM.
Reply With Quote
  #9  
Old 09-10-2014, 02:08 PM
jberry1954 jberry1954 is offline
What's HL7?
 
Join Date: Apr 2011
Posts: 2
jberry1954 is on a distinguished road
Default Deploy

I have the enable and disable working for the destinations, but am a little vague on the deploy part. Can you provide the exact code needed to re-deploy the channel after the destinations have been dis/en abled, please
Reply With Quote
  #10  
Old 09-10-2014, 02:27 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by jberry1954 View Post
I have the enable and disable working for the destinations, but am a little vague on the deploy part. Can you provide the exact code needed to re-deploy the channel after the destinations have been dis/en abled, please
Bottom line is, don't do it.

If you find the need to be manually enabling / disabling destinations, you're not using Mirth Connect correctly. You should really be taking a step back and deciding whether you actually need to do that, or whether it's something that can be done the right way by using destination filters or something else.

But if you do still want to redeploy a channel, you can. Since you did not specify I will assume you're working with the latest version (3.0.3). In 3.x you can use ChannelUtil:

Code:
ChannelUtil.deployChannel(channelIdOrName);
In 2.x it'll be a little different; you'll have to invoke an internal controller directly. Note that using internal Mirth Connect classes is not supported and is not guaranteed to work in future versions. The controller itself could be completely removed for example, and no prior notice or automatic migration of any kind will be done. In any case you'll need to get the controller:

Code:
var controller = com.mirth.connect.server.controllers.ControllerFactory.getFactory().createEngineController();
Then call the deployChannels method:

Code:
controller.deployChannels(java.util.Collections.singletonList('channel ID here'), null);
__________________
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

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 10:15 AM.


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