web stats
Deploying a channel from script - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2012, 06:01 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default Deploying a channel from script

What is the code for deploying a channel from scripts?

Is there some where that I can find this information other than posting here?
Reply With Quote
  #2  
Old 05-09-2012, 08:41 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

This has been asked a couple of times before I think, so I made a code template for it:

http://www.mirthcorp.com/community/f...9&postcount=12

Last edited by narupley; 05-09-2012 at 08:53 AM.
Reply With Quote
  #3  
Old 05-09-2012, 09:18 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

This looks like code from to call from outside the engine. I am trying to do this from another channel. We have channels that are not processing and messages are queuing up. Redeploying the channels often fixes this. We also have a channel that watches and alerts us when channels get too far in queue. I trying to reploy channel at this point, so that if we do have to go in and do it manually.
Reply With Quote
  #4  
Old 05-09-2012, 09:26 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

The code technically initiates a new RESTful client and issues commands, but that can be done within or without Mirth. That is to say, yes, you can use that function in a Mirth channel.

Last edited by narupley; 05-09-2012 at 12:14 PM.
Reply With Quote
  #5  
Old 05-09-2012, 12:16 PM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

var client = new com.mirth.connect.client.core.Client('10.29.186.20 ',10);
var loginStatus = client.login(user,password,'2.1.1.5490');

I get the error..

IllegalArgumentException: host parameter is null (694dcf4e-55a3-42b7-a9b3-d653de9f7ffb#2047)
Reply With Quote
  #6  
Old 05-09-2012, 12:26 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

Did you try using the code template I provided? If you look through my code, or in the actual Mirth code, you'll see that the first argument of the Client constructor is the Administrator HTTPS URL, not just an IP address. Also, 10 ms is too low of a timeout; it'll probably work since it's all on localhost, but you should still crank that up to like 10,000 or so.

For your server, you would probably want to do something like this:

Code:
logger.info(deployChannels(['channelid1','channelid2',.....],{user:user,pass:password,version:'2.1.1.5490'}).toString());

Last edited by narupley; 05-09-2012 at 12:40 PM.
Reply With Quote
  #7  
Old 05-31-2012, 05:31 PM
ramji1501 ramji1501 is offline
Mirth Newb
 
Join Date: Dec 2010
Posts: 19
ramji1501 is on a distinguished road
Unhappy Error

I tried this and got an error.

Appreciate any help.

ERROR (com.mirth.connect.server.controllers.MuleEngineCo ntroller:254): Error deploying channels.
java.lang.ClassCastException: java.lang.String cannot be cast to com.mirth.connect.model.Channel
Reply With Quote
  #8  
Old 06-01-2012, 03: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

Quote:
Originally Posted by ramji1501 View Post
I tried this and got an error.

Appreciate any help.

ERROR (com.mirth.connect.server.controllers.MuleEngineCo ntroller:254): Error deploying channels.
java.lang.ClassCastException: java.lang.String cannot be cast to com.mirth.connect.model.Channel
What code are you using, and what version are you on? If you want, you can post your channel too, these are always helpful things to include if you want others to help you troubleshoot...
Reply With Quote
  #9  
Old 06-01-2012, 04:46 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

In 2.1.1, for deploy, you must first convert the string to a channel class

var channel = com.mirth.connect.server.controllers.ChannelContro ller.getInstance().getCachedChannelById(channelId) ;

In 2.2.1, for deploy, it must be a string.

I ran into a problem with the channel not undeploying before the deploy, which leaves the channel undeployed. I had to explicitly undeploy channel, and wait for it to undeploy.


In 2.1.1 for undeploy, it must be a string. So, deploy requires a channel class and undeploy requires a string.

I have not implemented it yet on 2.2.1.
Reply With Quote
  #10  
Old 04-03-2013, 04:22 AM
Rebou Rebou is offline
What's HL7?
 
Join Date: Apr 2013
Posts: 1
Rebou is on a distinguished road
Default Same issue

Hi all,

I have the same error...

ERROR (com.mirth.connect.server.controllers.MuleEngineCo ntroller:254): Error deploying channels.
java.lang.ClassCastException: java.lang.String cannot be cast to com.mirth.connect.model.Channel

Someone has managed the deployment of channels without error?

Thanks and regards
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 01:43 PM.


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