concept consumer in category system administration

appears as: consumers, A consumer, consumer, The consumer, consumer, consumers
Securing DevOps

This is an excerpt from Manning's book Securing DevOps.

This is again an access-control problem: only systems with a particular purpose should receive a given type of secret. An accounting service shouldn’t be able to access the secrets of the order-management platform, and vice versa. The stakes can be even higher than with user-credential management, because in some cases it may not be possible to change the secrets following a leak. For example, cryptographic keys embedded with products sold to consumers must be kept securely forever, and often can’t be changed if leaked (leaving aside any security considerations of the fact that embedding keys in products is a sign of poor security design).

A message broker is an application that receives messages from publishers and routes them to consumers. It’s a fancy pipe with some smart logic to decide which consumer gets a copy of a given message.

Figure 7.5 Message brokers route messages between publishers (on the left) and consumers (on the right). Consumers subscribe to specific event topics, and message brokers use that information to route events correctly, possibly duplicating events to make sure all consumers get a copy. In this example, both the signature and rate analyzers get a copy of the messages sent by the system-logs publisher.

c07_05.png

On the consumer side of the message broker live the log consumers, which compose the third layer of our logging pipeline: the analysis layer. As we discussed in the previous section, log consumers receive event messages from the message broker, as shown in figure 7.6. We haven’t yet discussed what consumers might do with these messages.

Figure 7.6 The third layer of the logging pipeline contains log consumers that process and analyze events for various purposes. In this diagram, a storage module passes raw logs to a storage layer; a monitoring module computes metrics and raises alerts to operators as needed; and a security module catches anomalies and fraud and then alerts operators.

c07_06.png

The most basic component of the analysis layer is one that consumes raw events and writes them into a database in the storage layer. A logging pipeline should always retain raw logs for some period of time (90 days often seems to strike a reasonable compromise between retention cost and investigative needs). A consumer dedicated to this task can consume all messages sent to the broker and write them into a database or filesystem.

The pseudocode of such a consumer, shown in listing 7.10, is simple: the consumer starts by establishing a connection to the message broker and ask for copies of messages that match all topics. Most message brokers support some form of pattern matching to filter messages based on their topics, so the consumer only needs to request messages matching the wildcard topic to receive all of them.

The consumer then enters a loop that’s executed every time the broker forwards a message over the established connection. In each iteration of the loop, the consumer parses one log event. A normalization step happens here to convert values, like timestamp values, from various random formats into a single standard format. The normalized event is inserted into the database or written to the appropriate storage location, and the consumer acknowledges processing of the event to the broker to remove it from the queue.

Listing 7.10 Pseudocode of a storage consumer
consumer raw-storage:
 initialization:
  connect to message broker
  subscribe to all topics using wildcard pattern
 processing:
  for each message:
   parse message body
   normalize values into event structure
   insert event structure into database
   acknowledge consumption of message to broker

An important aspect of log consumers is their size: they should be small programs that perform a single task. A sophisticated logging pipeline may have dozens of consumers that do different things, and each runs autonomously. The message broker is the tie that binds them to the logging pipeline.

From an infrastructure perspective, consumers may run in various environments and be written in any language. A modern pattern is to run them in serverless environments, meaning that a third-party service like AWS Lambda takes care of running the underlying servers. This model entirely removes the need for managing systems and allows architects to focus on building modular systems by using lots of individual consumers.

Another common pattern is to run consumers as small plugins executed on top of a log-processing system, like Fluentd (www.fluentd.org/) or Logstash (www.elastic.co/products/logstash). These systems provide generic features to consume logs from various message brokers, pass them through custom analysis plugins defined by the operator, and write the output to a destination of choice. Both Logstash and Fluentd use plugins written in Ruby. At Mozilla, we wrote our own event-processing daemon called Hindsight (http://mng.bz/m4gg) which uses plugins written in Lua. We’ll discuss Hindsight further in chapter 8.

SOA Governance in Action

This is an excerpt from Manning's book SOA Governance in Action.

Table 1.4. Design and documentation policies

Name

Policy description

Create self-documenting services. All services should be self-documenting. You should be able to use a service without having to check a manual.
Reuse existing message standards. If there’s a standard or de facto model that’s used within your organization or business domain, you should use that model in your services.
Design for reusability. Before starting work on a new service, you must make sure that there isn’t a service already available that provides the same functionality or that can be easily modified to provide the required functionality.
Support multiple versions of services. It must be possible to support multiple versions of the same service next to each other. Changes in versions should affect the consumer as little as possible.

When you provide a service that handles financial requests or other types of transactions, it’s important that you can determine the validity of the messages you receive. You need to be sure, especially with sensitive requests, that the request wasn’t altered in transit and that you can determine that the consumers are who they say they are. The PermitService, mentioned in chapter 3, allows residents to request different kinds of permits. To obtain these permits residents usually will need to enter all kinds of personal information. You want to make sure that these messages aren’t intercepted or modified in any way. This could cause permits to be issued to incorrect addresses or in other residents’ names.

7.  The consumer can now upgrade their request token to an access token.

8.  The redirect from step 6 contains the request token, so the consumer knows which user it’s dealing with. The consumer now makes a request to upgrade a request token to an access token.

Registering a Consumer with the Service Provider

I’ll walk you through the steps and show you how to configure them. Before you start, though, you first need to tell the service provider that there’s a consumer who wants to access its resources. If you look back at the favorite movies and TV Guide example, this would mean the Favorite Movies service must know beforehand that it can expect requests from the TV Guide service to access information for some users. If you don’t restrict this to specific service consumers, any service could access information from the service provider. For this you need to get a consumer key and secret, which the consumer can use to identify itself and sign its messages. OpenAM provides functionality for this that you can use. If you open the following URL in your browser, http://localhost:8080/opensso/oauth/index.jsp, you’ll be shown a basic form (see figure 5.7) that you can use to register OAuth consumers in OpenAM.

Figure 5.7. OpenAM consumer registration screen

In this form you can register a consumer by entering a name in the Service Consumer Name field (in this example you use opengov) and clicking the Register button. You can optionally also use X.509 certificates for authentication, but for this example you won’t do that. After you click the button you’re shown the details of your registration (shown in figure 5.8).

Listing 8.2. Policy format to be stored in the repository
<policy name="Service documentation"> <statement>All services, REST and WS-* alike, must be self-documenting. There shouldn't be the need of extensive user manuals on how to Use the services we provide. </statement> <rationale>We want our customers to be able to use our services without the help of online documentation or calling the helpdesk. Creating self-documenting services will help us in keeping the Available documentation succinct and up to date. If our services are self-explanatory, consumers will have less need to call the helpdesk and we can focus on creating new services and functionality. </rationale> <implication>For all the WS-* based services the WSDL will serve as the base for the documentation. When registering a service in the repository, from this WSDL human readable documentation must be created and linked to this service. The REST services should use relations and links to show the Intent on how these services should be used. For REST services a text document must be created and stored in The repository together with the REST service definition. This document explains, in a human readable manner, how the service is to be used. </implication> </policy>
Azure in Action

This is an excerpt from Manning's book Azure in Action.

The most common reason for any limitation is the services layer that sits on top of the real SQL Servers and simulates SQL Server to the consumer. This abstraction away from the physical implementation, or the routing engine itself, is usually the cause. For example, you can’t use the USE command in any of your scripts. To get around this limitation, you’ll need to make a separate connection for each different database you want to connect with. You should assume that each of your databases are on different servers.

Figure 16.2. Producers place messages into the queue, and consumers get them out. Each queue can have multiple produces and consumers.

Consumer 1 gets a message (msg 1), and that message is marked invisible . Seconds later, consumer 2 performs a get operation as well. Because the first message (msg 1) is invisible, the queue responds with the next message (msg 2) .

Not long thereafter, consumer 1 finishes processing msg 1 and performs a delete operation on the message. As part of the delete operation, the queue checks the pop receipt consumer 1 provides when it passes in the message. This is to make sure consumer 1 is the most recent reader of the message in question. The receipt matches in this case, and the message is deleted.

Consumer 1 then does an immediate read, and gets msg 3. Consumer 1 fails to complete processing within the invisibility time window and fails to delete msg 3 in time. It becomes visible again.

Just at that time, consumer 2 deletes msg 2 and does a get. The queue responds with msg 3, because it’s visible again. While consumer 2 is processing msg 3, consumer 1 does finally finish processing msg 3 and tries to delete it. This time, the pop receipt, which consumer 1 has, doesn’t match the most recently provided pop receipt, which was given to consumer 2 when msg 3 was handed out for a second time. Because the pop receipt doesn’t match, an error is thrown, and the message isn’t deleted. You’ll likely see a 400 (Bad Request) error when this happens. The inner exception details will explain that there aren’t any messages with a matching pop receipt available in the queue to be deleted.