Skip to content
Sending to RabbitMQ...
 
Notifications
Clear all

Sending to RabbitMQ via Airtable

20 Posts
3 Users
0 Reactions
6 Views
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

Hi!

I'm retrieving a list from Airtable and need to send a single object from that list to the Rabbit exchanger. The example below isn't working as expected.

Problematic Example

  {
      "name": "",
      "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "callin.io-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "list",
        "application": "id_base",
        "table": "table",
        "additionalOptions": {
          "filterByFormula": "=type = "created""
        }
      },
      "name": "GetWorkouts",
      "type": "callin.io-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        493,
        536
      ],
      "credentials": {
        "airtableApi": "Airtable Alekseev"
      }
    },
    {
      "parameters": {
        "mode": "exchange",
        "exchange": "Exchange",
        "exchangeType": "topic",
        "routingKey": "rout_key",
        "sendInputData": false,
        "message": "={{JSON.stringify($node["GetWorkouts"].json["fields"])}}",
        "options": {}
      },
      "name": "SendingWorkouts",
      "type": "callin.io-nodes-base.rabbitmq",
      "typeVersion": 1,
      "position": [
        720,
        540
      ],
      "credentials": {
        "rabbitmq": "callin.io_rabbit"
      }
    }
      ],
      "connections": {
    "GetWorkouts": {
      "main": [
        [
          {
            "node": "SendingWorkouts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
      },
      "active": false,
      "settings": {}
    }
 
Posted : 04/04/2021 2:09 pm
RicardoE105
(@ricardoe105)
Posts: 18
Active Member
 

It appears the workflow wasn't pasted correctly. Could you please verify this? Additionally, could you explain how the data is being received from the RabbitMQ queue? What is the data structure within your Airtable base? Providing this information will help me create a functional example.

 
Posted : 04/04/2021 3:17 pm
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

I'm receiving an array from Airtable and need to send individual elements from this array to RabbitMQ.

Example data from Airtable (List)

[
    {
        "id": "id_record_1",
        "fields": {
            "index": 5,
            "type": "created",
            "sending_date": "2021-04-04",
            "message": "Hello is Test 1!",
            "user": [
                "user_id_1"
            ],
            "status": [
                "active"
            ],
            "last_name": [
                "Last_Name_1"
            ],
            "first_name": [
                "First_Name_1"
            ],
            "tg_id": [
                "tg_id_1"
            ]
        },
        "createdTime": "2021-04-04T12:41:01.000Z"
    },
    {
        "id": "id_record_2",
        "fields": {
            "index": 4,
            "type": "created",
            "message": "Hello is test 2!",
            "sending_date": "2021-04-04",
            "user": [
                "user_id_2"
            ],
            "status": [
                "active"
            ],
            "last_name": [
                "Last_Name_2"
            ],
            "first_name": [
                "First_Name_2"
            ],
            "tg_id": [
                "tg_id_2"
            ]
        },
        "createdTime": "2021-04-04T12:26:52.000Z"
    }
]

Each item in the array needs to be dispatched as a separate message. So, if there are 100 items, that would result in 100 messages being sent to RabbitMQ.

 
Posted : 04/04/2021 4:44 pm
RicardoE105
(@ricardoe105)
Posts: 18
Active Member
 

Ah, I see. My apologies for the initial misunderstanding. The example below should accomplish what you need.

```json
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "callin.io-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"functionCode": "return [
{
"json": {
"id": "idrecord1",
"fields": {
"index": 5,
"type": "created",
"sendingdate": "2021-04-04",
"message": "Hello is Test 1!",
"user": [
"user
id1"
],
"status": [
"active"
],
"last
name": [
"LastName1"
],
"firstname": [
"First
Name1"
],
"tg
id": [
"tgid1"
]
},
"createdTime": "2021-04-04T12:41:01.000Z"
},
},
{
"json": {
"id": "idrecord1",
"fields": {
"index": 5,
"type": "created",
"sendingdate": "2021-04-04",
"message": "Hello is Test 1!",
"user": [
"user
id1"
],
"status": [
"active"
],
"last
name": [
"LastName1"
],
"firstname": [
"First
Name1"
],
"tg
id": [
"tgid1"
]
},
"createdTime": "2021-04-04T12:41:01.000Z"
},

}
]"
},
"name": "Function",
"type": "callin.io-nodes-base.function",
"typeVersion": 1,
"position": [
520,
300
]
},
{
"parameters": {
"queue": "yourquue",
"options": {}
},
"name": "RabbitMQ",
"type": "callin.io-nodes-base.rabbitmq",
"typeVersion": 1,
"position": [
720,
300
],
"credentials": {
"rabbitmq": "asasasasasas"
}
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
},
"Function": {
"main": [
[
{
"node": "RabbitMQ",
"type": "main",
"index": 0
}
]
]
}
}
}
```

 
Posted : 04/04/2021 5:14 pm
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

Thanks for sending the examples. I'm observing different messages within the RabbitMQ logs.

The issue seems to be that when messages are retrieved from the queue, all three are being read as the most recently sent one.

For instance, if three messages are left in the queue and then three arrive, they are all processed as the last one sent, even though the RabbitMQ logs indicate that when the messages are fetched, they are indeed distinct.

 
Posted : 04/04/2021 7:13 pm
RicardoE105
(@ricardoe105)
Posts: 18
Active Member
 

You can likely read multiple messages from the queue. This would be a question related to RabbitMQ.

 
Posted : 04/04/2021 7:20 pm
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

Yes, it is being read.

However, I'm receiving three identical messages when only three unique messages are sent.

The workflow executes three times with the same message, even though the log shows that different messages were sent to RabbitMQ.

 
Posted : 04/04/2021 7:45 pm
jan
 jan
(@jan)
Posts: 39
Eminent Member
 

That's peculiar. I actually tested the RabbitMQ node earlier today, and when I sent three distinct messages, I received three distinct messages as well.

Do you have a sample workflow that demonstrates the issue you're encountering? Please share it.

 
Posted : 04/04/2021 8:51 pm
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

Yes, everything appears to be correct. The messages from RabbitMQ are received as they were sent. However, when I connect a few more nodes, something unusual happens: all messages are recorded as a single sent message.

My understanding is that each call, via RabbitMQ, should initiate the entire Workflow process from the beginning, correct?

Consumer Workflow

{
  "name": "CusDev_Workouts_Sending",
  "nodes": [
{
  "parameters": {},
  "name": "Start",
  "type": "n8n-nodes-base.start",
  "typeVersion": 1,
  "position": [
    250,
    300
  ]
},
{
  "parameters": {
    "operation": "update",
    "application": "app55LWjwlTcLazSI",
    "table": "workout",
    "id": "={{$node["RabbitTrigger"].json["id"]}}",
    "updateAllFields": false,
    "fields": [
      "type"
    ],
    "options": {}
  },
  "name": "SetDelivered",
  "type": "n8n-nodes-base.airtable",
  "typeVersion": 1,
  "position": [
    1030,
    550
  ],
  "credentials": {
    "airtableApi": "Airtable"
  }
},
{
  "parameters": {
    "chatId": "={{$node["RabbitTrigger"].json["fields"]["tg_id"][0]}}",
  "text": "={{$node["RabbitTrigger"].json["fields"]["message"]}}",
  "additionalFields": {}
  },
  "name": "SendWorkoutToUser",
  "type": "n8n-nodes-base.telegram",
  "typeVersion": 1,
  "position": [
    700,
    810
  ],
  "credentials": {
    "telegramApi": "Telegram CusDev Bot"
  },
  "disabled": true
},
{
  "parameters": {
    "keepOnlySet": true,
    "values": {
      "string": [
        {
          "name": "type",
          "value": "delivered"
        }
      ]
    },
    "options": {}
  },
  "name": "SetType",
  "type": "n8n-nodes-base.set",
  "typeVersion": 1,
  "position": [
    850,
    550
  ]
},
{
  "parameters": {
    "conditions": {
      "boolean": [
        {
          "value1": true,
          "value2": "={{$node["RabbitTrigger"]["json"]["fields"]["tg_id"] !== undefined}}"
        }
      ]
    }
  },
  "name": "TgIdExist?",
  "type": "n8n-nodes-base.if",
  "typeVersion": 1,
  "position": [
    450,
    650
  ]
},
{
  "parameters": {
    "queue": "cusdev_workouts",
    "options": {
      "durable": true,
      "jsonParseBody": true,
      "onlyContent": true
    }
  },
  "name": "RabbitTrigger",
  "type": "n8n-nodes-base.rabbitmqTrigger",
  "typeVersion": 1,
  "position": [
    270,
    550
  ],
  "credentials": {
    "rabbitmq": "n8n_rabbit"
  }
}
  ],
  "connections": {
"SetType": {
  "main": [
    [
      {
        "node": "SetDelivered",
        "type": "main",
        "index": 0
      }
    ]
  ]
},
"TgIdExist?": {
  "main": [
    [
      {
        "node": "SetType",
        "type": "main",
        "index": 0
      }
    ]
  ]
},
"RabbitTrigger": {
  "main": [
    [
      {
        "node": "TgIdExist?",
        "type": "main",
        "index": 0
      }
    ]
  ]
}
  },
  "active": false,
  "settings": {
"executionTimeout": 300,
"saveExecutionProgress": "DEFAULT",
"errorWorkflow": "23"
  },
  "id": "25"
}
 
Posted : 05/04/2021 7:17 am
jan
 jan
(@jan)
Posts: 39
Eminent Member
 

Apologies, I don't quite grasp your meaning.

I'm uncertain at the moment if it's feasible for multiple messages to arrive concurrently. If this is the case, you could attempt to modify the expression in the Airtable Node's "SetDelivered" field from

{{$node["RabbitTrigger"].json["id"]}}

to

{{json["id"]}}

 
Posted : 05/04/2021 7:54 am
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

An empty field appears when updating Airtable, leading to an error.

 
Posted : 06/04/2021 6:12 pm
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

Video demonstrating the issue - https://drive.google.com/file/d/1Wn1Ps0QDDCbtTINgu5H3mASKNAWIzCOK/view?usp=sharing

My understanding is that a single message corresponds to a single thread and a single processing context. Is this the intended behavior?

 
Posted : 06/04/2021 8:17 pm
jan
 jan
(@jan)
Posts: 39
Eminent Member
 

Correct, it should typically initiate one workflow execution for each message. This also appears to be what's happening in the video. You sent 3 messages, and the workflow started 3 times, once for each message.

Apologies, perhaps it's too late, but I unfortunately don't understand what is meant to be wrong in that video. Are you suggesting all three workflows contain identical data? If so, the video doesn't demonstrate that, as you're only opening one execution and not the other two.

Please provide the rewritten markdown content.

 
Posted : 06/04/2021 10:16 pm
a1ekseev
(@a1ekseev)
Posts: 10
Active Member
Topic starter
 

I've updated the video, please check it out again. Apologies for the poor quality in the previous post.

https://drive.google.com/file/d/1s2GLCHEyhacvOlEL-jqXWFrdhwhGsPyJ/view?usp=sharing

 
Posted : 07/04/2021 8:48 pm
jan
 jan
(@jan)
Posts: 39
Eminent Member
 

Apologies, but the current quality is extremely poor (360p), making it impossible for me to discern anything.

Could you please provide the rewritten markdown content? It should be in markdown format.

 
Posted : 07/04/2021 8:53 pm
Page 1 / 2
Share: