Skip to content

Commit 50a5034

Browse files
committed
Ability to connect to Java Gateway directly, without using Ensemble service
1 parent c7baa10 commit 50a5034

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

RabbitMQ/Common.cls

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ Property VirtualHost As %String [ InitialExpression = "/" ];
1111

1212
Property Queue As %String;
1313

14-
/// Config Name of the Java Gateway service controlling the Java Gateway server this Operation will use.
14+
/// Config Name of the Java Gateway service controlling the Java Gateway server this item will use.
15+
/// Alternatively use JGHost and JGPort Settings, to specify Java gateway outside of Ensemble scope.
1516
Property JGService As %String;
1617

18+
/// Hostname of the Java Gateway server this item will use.
19+
/// Alternatively use JGService Setting, to specify Java gateway inside Ensemble.
20+
Property JGHost As %String;
21+
22+
/// Port of the Java Gateway server this item will use.
23+
/// Alternatively use JGService Setting, to specify Java gateway inside Ensemble.
24+
Property JGPort As %Integer;
25+
1726
/// Gateway connection
1827
Property JGW As %Net.Remote.Gateway;
1928

@@ -31,7 +40,7 @@ Property Encoding As %String;
3140
Property ClassPath As %String(MAXLEN = 32000);
3241

3342
/// These are the production settings for this object
34-
Parameter SETTINGS = "Host:Basic,Port:Basic,VirtualHost:Basic,Queue:Basic,Credentials:Basic:credentialsSelector,JGService:Basic:selector?context={Ens.ContextSearch/ProductionItems?targets=0&productionName=@productionId},ClassPath:Basic,Encoding:Basic";
43+
Parameter SETTINGS = "Host:Basic,Port:Basic,VirtualHost:Basic,Queue:Basic,Credentials:Basic:credentialsSelector,JGHost:Java Gateway,JGPort:Java Gateway,JGService:Java Gateway:selector?context={Ens.ContextSearch/ProductionItems?targets=0&productionName=@productionId},ClassPath:Basic,Encoding:Basic";
3544

3645
/// Connect to running JGW
3746
Method Connect() As %Status
@@ -44,8 +53,14 @@ Method Connect() As %Status
4453

4554
// get a connection handle and connect
4655
Set gateway = ##class(%Net.Remote.Gateway).%New()
47-
Set host = ##class(Ens.Director).GetHostSettingValue(..JGService, "Address")
48-
Set port = ##class(Ens.Director).GetHostSettingValue(..JGService, "Port")
56+
If ..JGService'="" {
57+
Set host = ##class(Ens.Director).GetHostSettingValue(..JGService, "Address")
58+
Set port = ##class(Ens.Director).GetHostSettingValue(..JGService, "Port")
59+
} Else {
60+
Set host = ..JGHost
61+
Set port = ..JGPort
62+
}
63+
4964
Set sc = gateway.%Connect(host, port, $namespace, timeout, classPath)
5065

5166
If $$$ISOK(sc) {

RabbitMQ/InboundAdapter.cls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Parameter SETTINGS = "BodyClass:Basic";
1010
Method OnInit() As %Status
1111
{
1212
Set sc = $$$OK
13-
Quit:..JGService="" $$$ERROR($$$GeneralError,"Specify JGService setting")
14-
Quit:'##class(Ens.Director).IsItemEnabled(..JGService) $$$ERROR($$$GeneralError, $$$FormatText("Java Gateway Service: '%1' is down",..JGService))
13+
Quit:((..JGService="") && ((..JGHost="") || (..JGPort = ""))) $$$ERROR($$$GeneralError,"Specify JGService setting or JGHost and JGPort settings")
14+
Quit:((..JGService'="") && '##class(Ens.Director).IsItemEnabled(..JGService)) $$$ERROR($$$GeneralError, $$$FormatText("Java Gateway Service: '%1' is down",..JGService))
1515
Set sc = ..Connect()
16-
Quit:$$$ISERR(sc)
16+
Quit:$$$ISERR(sc) sc
1717
Set sc = ..ConnectToRabbitMQ()
1818
Quit sc
1919
}

RabbitMQ/OutboundAdapter.cls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Class RabbitMQ.OutboundAdapter Extends (Ens.OutboundAdapter, RabbitMQ.Common)
22
{
33

4+
/// Establish gateway connection and init java API.
45
Method OnInit() As %Status
56
{
67
Set sc = $$$OK
7-
Quit:..JGService="" $$$ERROR($$$GeneralError,"Specify JGService setting")
8-
Quit:'##class(Ens.Director).IsItemEnabled(..JGService) $$$ERROR($$$GeneralError, $$$FormatText("Java Gateway Service: '%1' is down",..JGService))
8+
Quit:((..JGService="") && ((..JGHost="") || (..JGPort = ""))) $$$ERROR($$$GeneralError,"Specify JGService setting or JGHost and JGPort settings")
9+
Quit:((..JGService'="") && '##class(Ens.Director).IsItemEnabled(..JGService)) $$$ERROR($$$GeneralError, $$$FormatText("Java Gateway Service: '%1' is down",..JGService))
910
Set sc = ..Connect()
1011
Quit:$$$ISERR(sc) sc
1112
Set sc = ..ConnectToRabbitMQ()

0 commit comments

Comments
 (0)