Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
eduard93 committed Dec 9, 2019
1 parent 2221776 commit 34316ee
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
15 changes: 13 additions & 2 deletions isc/rabbitmq/Common.cls
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,23 @@ Method ConnectToRabbitMQ() As %Status

Try {
Set ..API = ##class(isc.rabbitmq.API).%New(..JGW, ..Host, ..Port, user, pass, ..VirtualHost, ..Queue, $$$YES)
} Catch ex {
Set sc = $$$ADDSC(ex.AsStatus(),$g(%objlasterror))
} Catch ex {
Set sc = ..ExceptionToStatus(ex)
}

Quit sc
}

Method ExceptionToStatus(ex As %Exception.General) As %Status
{
#Dim sc As %Status
If ((ex.Name="<ZJGTW>") && $d(%objlasterror)) {
Set sc = %objlasterror
} Else {
Set sc = ex.AsStatus()
}
Quit sc
}

}

13 changes: 11 additions & 2 deletions isc/rabbitmq/InboundAdapter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@ Method OnTask() As %Status
#Dim messageList As %ListOfDataTypes

If ..BodyClass = "" {
Set messageList = ..API.readMessageString()
Try {
Set messageList = ..API.readMessageString()
} Catch ex {
Set sc = ..ExceptionToStatus(ex)
}
} Else {
#Dim tempStream As %Library.GlobalBinaryStream
Set messageList = ##class(%ListOfDataTypes).%New()
For i=1:1:15 Do messageList.Insert("")
Set tempStream = ..API.readMessageStream(.messageList)
Try {
Set tempStream = ..API.readMessageStream(.messageList)
} Catch ex {
Set sc = ..ExceptionToStatus(ex)
}
}
Quit:$$$ISERR(sc)

Set messageLength = messageList.GetAt(1)
Set messageCount = messageList.GetAt(2)
Expand Down
4 changes: 2 additions & 2 deletions isc/rabbitmq/OutboundAdapter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Method SendMessage(message As %Stream.Object) As %Status
Try {
Do ..API.sendMessage(stream)
} Catch ex {
Set sc = ex.AsStatus()
Set sc = ..ExceptionToStatus(ex)
}
Quit sc
}
Expand All @@ -63,7 +63,7 @@ Method SendMessageToQueue(queue As %String, message As %Stream.Object) As %Statu
Try {
Do ..API.sendMessageToQueue(queue, stream)
} Catch ex {
Set sc = ex.AsStatus()
Set sc = ..ExceptionToStatus(ex)
}
Quit sc
}
Expand Down
4 changes: 2 additions & 2 deletions isc/rabbitmq/Production.cls
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ XData ProductionDefinition
<Production Name="isc.rabbitmq.Production" TestingEnabled="true" LogGeneralTraceEvents="false">
<Description></Description>
<ActorPoolSize>2</ActorPoolSize>
<Item Name="isc.rabbitmq.Service" Category="" ClassName="RabbitMQ.Service" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule="">
<Item Name="isc.rabbitmq.Service" Category="" ClassName="isc.rabbitmq.Service" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="true" Schedule="">
<Setting Target="Adapter" Name="JGService">EnsLib.JavaGateway.Service</Setting>
<Setting Target="Adapter" Name="ClassPath">C:\InterSystems\RabbitMQjava.jar;C:\InterSystems\Java\amqp-client-5.7.2.jar</Setting>
<Setting Target="Adapter" Name="Queue">hello</Setting>
Expand All @@ -20,7 +20,7 @@ XData ProductionDefinition
<Setting Target="Host" Name="JavaHome">C:\Progra~1\Java\jdk1.8.0_121\</Setting>
<Setting Target="Host" Name="ClassPath">C:\InterSystems\RabbitMQjava.jar;C:\InterSystems\Java\amqp-client-5.7.2.jar</Setting>
</Item>
<Item Name="isc.rabbitmq.Operation" Category="" ClassName="RabbitMQ.Operation" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Item Name="isc.rabbitmq.Operation" Category="" ClassName="isc.rabbitmq.Operation" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="JGService">EnsLib.JavaGateway.Service</Setting>
<Setting Target="Adapter" Name="Queue">hello</Setting>
<Setting Target="Adapter" Name="ClassPath">C:\InterSystems\RabbitMQjava.jar;C:\InterSystems\Java\amqp-client-5.7.2.jar</Setting>
Expand Down

0 comments on commit 34316ee

Please sign in to comment.