How do I find out which exchange routed a message last? - rabbitmq

We are intending to build up a one way network of exchange-to-exchange bindings. Our requirement is to attach the route a message took to its header, but there seems to be no way to find out which exchange handled a message last.
I already tried looking up the information using the tracing functionality and there also exists a plugin that subscribes to the internal basic.publish event. Yet, all these ways just give me the exchange of first entry.
I even took a look at the rabbitmq-server source code and it seems like there is no possible extension point inside the routing function (see headers exchange routing for example). I am not an Erlang dev, so maybe there is an Erlang way of intercepting/extending functions to be called?
Example
+---------+
| |
| POE |
| |
+--+--+---+
| |
+-------+ | | +-------+
| | | | | |
| EX1 +---+ +----+ EX2 |
| | | |
+--+----+ +---+---+
| |
| |
| |
+--+----+ +---+---+
| | | |
| QU1 | | QU2 |
| | | |
+-------+ +-------+
For a message that ends up in QU2 we would like to have a header field like this:
{...
x-route, ["POE", "EX2"]
}

This could probably be accomplished with a RabbitMQ plugin but it would be difficult to do: a channel interceptor would have to effectively do a part of the routing to determine the "last" exchange. There could be more than one "last" exchange, as well.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Related

How to create Header over Header

Table:
id | BL | ML |BL | ML
---------------------------------------------------------
1 | Field01 |Name | Field34 | Field36
2 | Field02 |Age | Field35 | Field37
Required result:
Id | Open | Closed
---------------------------------------------------------
| BL | ML |BL | ML
---------------------------------------------------------
1 | Field01 |Name | Field34 | Field36
2 | Field02 |Age | Field35 | Field37
This is not possible in just SQL Server. You should be handling this type of display within your presentation tool.
It seems weird to do this kind of thing in SQL Server. I don't think you can even do this in SQL Server. If you have access to Python, you can use Python to do this kind of thing, which is called a MultiIndex. This may be going off on a tangent, but you can refer to the link below as to how to create a MultiIndex.
https://jakevdp.github.io/PythonDataScienceHandbook/03.05-hierarchical-indexing.html

Can we go back in .net core middleware pipeline

My question is can we go back to middle ware pipeline let see an example
we have middleware1, middlware2, middleware3 and middlware3 is executing. I want middleware1 to execute again and then control back to middleware3 can we do that ?
Thank in advance
No, you cannot do that. The middlewares are called in a pipeline. That means, there is one middleware which will start and which will pass on to the next middleware in the pipeline, which will then pass on to the next, and so on. Eventually, each middleware has a way to do something afterwards as the pipeline completes.
This generally looks like this:
Request
| → Middleware1
| | run
| | next() → Middleware2
| | | run
| | | next() → Middleware3
| | | | run
| | | | next() → {}
| | | | run after
| | | | return ↵
| | | ←
| | | run after
| | | return ↵
| | ←
| | run after
| | return ↵
| ←
| ⇒ Send response
Since this is a strict pipeline that only goes in a single direction, you cannot randomly jump around. You only get the chance to call the next middleware in the pipeline or return.
What you can do however is invoke the following pipeline multiple times. For example, the StatusCodePages middleware does this to re-execute the pipeline for the status code page when an error occurs:
Request
| → StatusCodePagesMiddleware
| | run
| | next() → Pipeline
| | | … throw an error
| | ← catch exception
| | run after
| | adjust parameters
| | next() → Run pipeline again with modified parameters do display error page
| | return ↵
| ←
| ⇒ Send response
Note that this is a very special thing which only works because the StatusCodePages middleware is usually registered very early and because it wants to rerun the full pipeline.
If you want finer control over this, chances are you shouldn’t even split your logic up into multiple middlewares. It might be a better idea to have a single middleware that just has a very controlled logic inside. That logic could for example be another pipeline, or just a straightforward control flow.

Intellij IDEA: creating a pane under the source code

Having used Eclipse for more years than I care to admit, I'm currently trying to get adjusted to IntelliJ (2016.2, Community) but I'm having a hard time with the totally different UI metaphors/concepts.
I'd like to be able to have a window layout like this:
+--------+------------------------
| | |
| (1) | |
| | |
|+-------+ Source editor |
| | |
| (2) | |
| |-----------------------+
| | |
| | Console output etc. |
+--------+-----------------------+
Luckily, this question helped me with splitting panes to get (1) and (2).
However, I have not been able to find out how to rearrange tool windows so that I can get a (for example) Terminal tool window that is directly underneath the source editor pane, instead of one that looks like this:
+--------+------------------------
| | |
| (1) | |
| | |
|+-------+ Source editor |
| | |
| (2) | |
+--------------------------------+
| |
| Console output etc. |
+--------------------------------+
Open "Settings" > "Appearance & Behavior" > "Appearance" and enable "Widescreen tool window layout".
Tested in DataGrip and PyCharm. Should be exactly the same in IDEA, Webstorm as far as i know - i used them all and the UI is the same everywhere (and i like that).
You could just float the panels next to your IntelliJ main windows like this screenshot.

Problems with using the bootstrap-datepicker in Fitnesse Tests

In my Fitnesse Tests I want to enter dates through datepicker elements. Sometimes it works. But most of the time a different date, unlike the date that was entered, appears. Here is an example:
| ensure | do | type | on | id=field_id | with | |
| ensure | do | type | on | id=field_id | with | 05.05.1997 |
| check | is | verifyValue | on | id=field_id | [28.05.1997] expected [05.05.1997] |
(To make sure that the field isn't already filled, I pass an empty String first.)
Mostly, the 'day'-statement is different from what was entered. Do you know the reason for this behavior? How can I solve this?
Thanks in advance!
This is related to how you wrote your fixture and not FitNesse, the problem is that it returns a different value and also implies that the previous line didn't work - | ensure | do | type | on | id=field_id | with | 05.05.1997 |

SQL - Combining 3 rows per group in a logging scenario

I have reworked our API's logging system to use Azure Table Storage from using SQL storage for cost and performance reasons. I am now migrating our legacy logs to the new system. I am building a SQL query per table that will map the old fields to the new ones, with the intention of exporting to CSV then importing into Azure.
So far, so good. However, one artifact of the previous system is that it logged 3 times per request - call begin, call response and call end - and the new one logs the call as just one log (again, for cost and performance reasons).
Some fields common are common to all three related logs, e.g. the Session which uniquely identifies the call.
Some fields I only want the first log's value, e.g. Date which may be a few seconds different in the second and third log.
Some fields are shared for the three different purposes, e.g. Parameters gives the Input Model for Call Begin, Output Model for Call Response, and HTTP response (e.g. OK) for Call End.
Some fields are unused for two of the purposes, e.g. ExecutionTime is -1 for Call Begin and Call Response, and a value in ms for Call End.
How can I "roll up" the sets of 3 rows into one row per set? I have tried using DISTINCT and GROUP BY, but the fact that some of the information collides is making it very difficult. I apologize that my SQL isn't really good enough to really explain what I'm asking for - so perhaps an example will make it clearer:
Example of what I have:
SQL:
SELECT * FROM [dbo].[Log]
Results:
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| Session | Date | Level | Context | Message | ExecutionTime | Parameters | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Begin | -1 | {"Input":"xx"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Response | -1 | {"Output":"yy"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call End | 123 | OK | |
| F76BCBB | 2014-07-20 19:16:17 | ERROR | GET v1/def | Call Begin | -1 | {"Input":"ww"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call Response | -1 | {"Output":"vv"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call End | 456 | BadRequest | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
Example of what I want:
SQL:
[Need to write this query]
Results:
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| Date | Level | Context | Message | ExecutionTime | InputModel | OutputModel | HttpResponse |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| 2014-07-20 19:16:15 | INFO | GET v1/abc | Api Call | 123 | {"Input":"xx"} | {"Output":"yy"} | OK |
| 2014-07-20 19:16:17 | ERROR | GET v1/def | Api Call | 456 | {"Input":"ww"} | {"Output":"vv"} | BadRequest |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
select L1.Session, L1.Date, L1.Level, L1.Context, 'Api Call' AS Message,
L3.ExecutionTime,
L1.Parameters as InputModel,
L2.Parameters as OutputModel,
L3.Parameters as HttpResponse
from Log L1
inner join Log L2 ON L1.Session = L2.Session
inner join Log L3 ON L1.Session = L3.Session
where L1.Message = 'Call Begin'
and L2.Message = 'Call Response'
and L3.Message = 'Call End'
This would work in your sample.