Handle Message with Async AGI

Hi, I’m trying to use async agi to receive messages and handle them in an asterisk-java agi-script.
The agi-script is triggered and soon as i start to execute AMI AgiActions to get different variables I receive the following error response:

org.asteriskjava.manager.response.ManagerError: actionId='null'; message='Channel **Message/ast_msg_queue does not exist**.'; response='Error'; uniqueId='null'; systemHashcode=1459834603

I’m starting to question if this is possible and appreciate any help on this topic.
The end goal is to be able to process and respond to messages in parallel in order to avoid blocking
incoming messages with the normal AGI() call since message processing can be quite lengthy in the environment this will be used.

My message_context in extensions.conf

[message]
exten => _.,1, NoOp(Async AGI)
same => n, AGI(agi:async)

Debug prints from the asterisk log:

Agi and manager log from asterisk CLI on an incoming message:

<Message/ast_msg_queue>AGI Tx >> agi_request: async
<-- Examining AMI event: -->
Event: Newchannel
Privilege: call,all
SequenceNumber: 18
File: manager_channels.c
Line: 756
Func: channel_snapshot_update
Channel: Message/ast_msg_queue
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: <unknown>
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: en
AccountCode: 
Context: default
Exten: s
Priority: 1
Uniqueid: 1656332467.0
Linkedid: 1656332467.0


<Message/ast_msg_queue>AGI Tx >> agi_channel: Message/ast_msg_queue
<Message/ast_msg_queue>AGI Tx >> agi_language: en
<Message/ast_msg_queue>AGI Tx >> agi_type: Message
<Message/ast_msg_queue>AGI Tx >> agi_uniqueid: 1656332467.0
<Message/ast_msg_queue>AGI Tx >> agi_version: certified/16.8-cert2
<Message/ast_msg_queue>AGI Tx >> agi_callerid: unknown
<Message/ast_msg_queue>AGI Tx >> agi_calleridname: unknown
<Message/ast_msg_queue>AGI Tx >> agi_callingpres: 67
<Message/ast_msg_queue>AGI Tx >> agi_callingani2: 0
<Message/ast_msg_queue>AGI Tx >> agi_callington: 0
<Message/ast_msg_queue>AGI Tx >> agi_callingtns: 0
<Message/ast_msg_queue>AGI Tx >> agi_dnid: unknown
<Message/ast_msg_queue>AGI Tx >> agi_rdnis: unknown
<Message/ast_msg_queue>AGI Tx >> agi_context: message
<Message/ast_msg_queue>AGI Tx >> agi_extension: s
<Message/ast_msg_queue>AGI Tx >> agi_priority: 2
<Message/ast_msg_queue>AGI Tx >> agi_enhanced: 0.0
<Message/ast_msg_queue>AGI Tx >> agi_accountcode: 
<Message/ast_msg_queue>AGI Tx >> agi_threadid: 139823061436160
<Message/ast_msg_queue>AGI Tx >> 
<-- Examining AMI event: -->
Event: AsyncAGIStart
Privilege: agi,all
SequenceNumber: 21
File: manager.c
Line: 1855
Func: manager_default_msg_cb
Channel: Message/ast_msg_queue
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: <unknown>
CallerIDName: <unknown>
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: en
AccountCode: 
Context: message
Exten: s
Priority: 2
Uniqueid: 1656332467.0
Linkedid: 1656332467.0
Env: agi_request%3A%20async%0Aagi_channel%3A%20Message%2Fast_msg_queue%0Aagi_language%3A%20en%0Aagi_type%3A%20Message%0Aagi_uniqueid%3A%201656332467.0%0Aagi_version%3A%20certified%2F16.8-cert2%0Aagi_callerid%3A%20unknown%0Aagi_calleridname%3A%20unknown%0Aagi_callingpres%3A%2067%0Aagi_callingani2%3A%200%0Aagi_callington%3A%200%0Aagi_callingtns%3A%200%0Aagi_dnid%3A%20unknown%0Aagi_rdnis%3A%20unknown%0Aagi_context%3A%20message%0Aagi_extension%3A%20s%0Aagi_priority%3A%202%0Aagi_enhanced%3A%200.0%0Aagi_accountcode%3A%20%0Aagi_threadid%3A%20139823061436160%0A%0A


<--- Examining AMI action: -->
action: Challenge
actionid: 1675251804_0#
authtype: MD5

<--- Examining AMI action: -->
action: Login
actionid: 1675251804_1#
key: 74b7e14db2957cd1a0ee9cbd2c1f6129
authtype: MD5
username: usr

<--- Examining AMI action: -->
action: CoreSettings
actionid: 1675251804_2#

<--- Examining AMI action: -->
action: AGI
actionid: 1675251804_3#
channel: Message/ast_msg_queue
commandid: 2
command: GET FULL VARIABLE ${MESSAGE(to)}

<--- Examining AMI action: -->
action: AGI
actionid: 967442214_3#
channel: Message/ast_msg_queue
command: SET VARIABLE "AJ_AGISTATUS" "SUCCESS"

<--- Examining AMI action: -->
action: AGI
actionid: 967442214_4#
channel: Message/ast_msg_queue
command: ASYNCAGI BREAK

The Agi script service function:

public void service(AgiRequest request, AgiChannel channel) throws AgiException {
				try {
					if (isManagerDisconnected()) {
						managerConnection.login();
					}
					
					int uuid = UUID.randomUUID().variant();
					String commandId = Integer.toString(uuid);
					AgiAction action = new AgiAction(channel.getName(),
							"GET VARIABLE MESSAGE(to)", commandId);
					ManagerResponse response = managerConnection.sendAction(action, 5000);
					if (response != null) {
						logger.info("Response: " + response.getResponse());
						logger.info("Output: " + response.getOutput());
					} else {
						logger.info("Response timeout....");
					}
				} catch (Exception e) {logger.warn(e);}

		}

The message channel is special, I don’t believe it would work with Async AGI.

Thanks for the fast response! I started to suspect that…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.