Why do developers need a business service bus?

xiaoxiao2021-03-31  207

This article is not only prepared for architect: Enterprise Service Bus, which will also make developers easier to work more easily as an Enterprise Service Bus, as an infrastructure that supports service-oriented architecture (SOA).

introduction

Important applications are rarely existing; if they cannot be used with other applications, the application will be difficult to play a big role. Service-oriented architecture often integrates applications so they can work together and improve work efficiency, each application is divided into each part of each other. SOA Model - Service Users call service providers - may seem quite simple, but it has put forward two important issues:

How do users find how they need to call the service providers to call the service quickly and reliably, and the network is actually slow and unreliable?

For these two questions, there is a fairly simple answer, ie the method called a business service bus (ESB). ESB handles all complex issues between users and providers, making service calls simple for both. ESB not only makes the application (or its various parts) more easily call services, but also helps them convert data and broadcast event notifications. ESB design reflects many design patterns and standard specifications that have been accepted by everyone.

This article is intended to help developers understand the ESB's role and the necessary part of the application integration (including SOA). The focus is not defined or the product, but the ESB implementation, so you don't have to implement these features yourself. It shows what ESB can do for you.

Call service

In order to help you understand the application integration and SOA, I will start from how to introduce Web services. Web services are just a way you can use to implement service calls. They may even be the best way, but they are the most standard way available, they can help me form the design of the task being tried.

First, I must explain the related terms. Web services are very similar to process-programming features: it has name, parameters, and results. The name is the Unified Resource Identifier (URI), through the URI, the web service provider makes the web service as endpoints. The web service user puts the endpoint URI as the address of the lookup and calling the Web service. When the user calls the endpoint, the request is transmitted to the web service, and the request includes specific operations and parameters. After the service is executed, the endpoint transmits the response back to the user, the response indicates success (or error), and contains the result of the service. In this way, the user can call the provider's endpoint, incoming request, and get a response.

Currently, the way to implement a web service is WS-I Basic Profile 1.1, which includes SOAP 1.1 Over HTTP 1.1, the latter is defined by the Web Service Description Language (WSDL) 1.1. (See References to get links to specifications itself.) Has SOAP over HTTP, and users can call services that bind HTTP messages in the HTTP request. The user synchronously blocks the HTTP socket, waiting for the HTTP response that contains the SOAP response. The endpoint API is described by the user and provider.

Since you understand the terms, let's take a look at the communication options for the user to call the service: Synchronize or asynchronously.

Synchronization and asynchronous call

Users can simultaneously implement service calls synchronously or asynchronously. From the user's point of view, the differences between these two methods are:

Synchronization - users call services via a single thread; the thread sends a request, blocking the service running, and waits for a response. Asynchronous - users call the service by two threads; one thread sends a request, while the other separate thread receives a response.

The terminology synchronization and asynchronous are often confused with the order and concurrent. The two terms behind are related to the order in which the individual tasks must be followed, while synchronous and asynchronous and threads perform a single task (such as call a single service). Understanding the different good ways between synchronous and asynchronous calls is to consider the consequences of crash recovery: Synchronize - If the user crashes when the service is blocked, when it is restarted, it will not be able to reconnect. To the ongoing call, the response is lost. Users must repeat the calling process and expect this time no crash. Asynchronous - If the user will crash when the request is sent after the request is sent, it can continue to wait for a response when it is restarted, so the response will not be lost.

Crash recovery is not the only difference between synchronous and asynchronous calls, but if you try to determine which way to use, consider how each call handles crash recovery, which usually gives you a good answer.

Since you understand the user's choice for the service call communication, you can see the user's choice for connection to the provider. Users can select one from the following communication mode:

Synchronous Direct call synchronization proxy call asynchronous agent call

I will explain each way separately.

Synchronous directly

The SOAP OVER HTTP mode that calls the web service is direct: Very similar to the execution function call, the user knows the address of the endpoint, and calls it directly. To make the call success, the web service must be available when the user calls the endpoint, and must respond before the user timeout. If you deploy a web service to a new location (such as different Internet domains), you must let the user know the new URI of the endpoint. To deploy multiple providers with the same service type, you must deploy each provider's endpoint to different URIs. To choose between different service providers, users must know each of them.

For example, consider a simple Web service for obtaining stock quotes: Users pass the stock code, and then retrieve the current price of the stock. This service may be provided by multiple different agents, each company has a different Internet URL. Getting a URL of the web service is a question that has a first chicken or an egg. If the user knows the location of the endpoint, it can ask if the service is what the address is, but the user needs to know the address to ask the address.

To solve this problem, unified description, universal description discovery and integration, uddi, is a web service, which is a directory similar to the phone book for finding other web services. The idea is to deploy UDDI to a well-known address that users already know, and then users can use UDDI to find other web services.

For stock quotation services, users know the address of the UDDI service, and the UDDI service also knows the address of the stock quotation service, as shown in Figure 1.

Figure 1: Direct calls Web services

Figure 2 shows how the user uses the UDDI service to find the endpoint of the stock quotation provider, and call one endpoint. The process works as follows:

Users ask the UDDI to ask the service provider list. The user selects a provider's endpoint from the list returned by UDDI. The user calls this endpoint.

Figure 2: Synchronous direct service call

Note that the selection provider's algorithm is completely decided by the user; in this case, the user selects only the first one in the list. The actual implementation may be complex.

It should also be noted that because the service endpoint may change, it should be re-query UDDI when the user needs to call the service, check whether the details of the provider have changed. Must for each service call query UDDI greatly increases the overhead of the calling service, especially if the provider's details are usually not changed. Synchronous agent call

The shortcomings of direct calling methods are that the user must know the URI of the provider's endpoint to call the service. It uses UDDI as a directory for finding the URI. If the provider changes the URI of its endpoint, it must register to the UDDI server so that the UDDI has a new URI, and then the user must re-query UDDI to get a new URI. In fact, this means that each user needs to call the service, it must query UDDI to find the endpoint URI and select it from it. This causes the user to waste many times in a repeated lookup UDDI and select the provider. This approach also enables the user to select the provider from a list that appears in a manner.

A method of simplifying this problem is to introduce Broker as an intermediary that calls Web services. Users no longer call the service provider directly, but call the service agent in Broker, and the service agent calls the service provider. The user needs to know the URI of the agent endpoint so that the UDDI lookup address, but in this example, UDDI only returns a single URI, so the user does not have to choose. Users don't even realize endpoints in the agent; just know that it can use this URI to call the web service. Broker coordinates the user and service provider, as shown in Figure 3.

Figure 3: Synchronous Enterprise Service Bus

The URI of the agent should be stable: After the user uses the UDDI to get the agent's URI, it first calls the service, in the future call, the user can reuse the URI (before at least before the agent stops working). At the same time, the agent tracking provider and its URI (possibly change between the calls), are they available (did the last call failed?), Their load (last call spent how long), and so on. The agent then is responsible for selecting the best provider for each call, eliminating the responsibility of the user. Every time the user calls the same agent at the same address, the agent is responsible for coordinating various providers.

Figure 4 shows how users use the Broker call service, the working mode is as follows:

The user requests a list of service providers to the UDDI. The URI returned by the UDDI is actually the URI of the service agent. UDDI only returns a URI instead of multiple URI, because Broker only uses a proxy for a specific service. Users use the agent's URI call service. The service agent selects the service provider from its available provider list. The service agent calls the endpoint of the selected provider.

Figure 4: Synchronous proxy service call

Please note that the work of selecting the provider has been turned away from the user, and now encapsulates in the Broker agent. This simplifies the user's work. Finally, the selection process used by the agent may differ from the selection process used by the user. However, because the UDDI server and agent are encapsulated in the Broker, it is more easily improved to improve the efficiency of some aspects, such as caching information in the agent, becoming the cached information to make the UDDI server notify the agent.

It should also be noted that because the address of the agent is stable, the user does not have to repeatedly query UDDI, and each service call is only queried. More specifically, the user only needs to query UDDI once, and then securely caching the agent's address and repeatedly uses it to call the service. This greatly reduces the overhead of the calling service.

Asynchronous agent call

The shortcomings of the synchronization method is that the user must block when the service is executed - the thread must be blocked when the service is running. If the service spends for a long time, the user may give up before receiving the response. When the user issues a request, if there is no service provider is running or they are overloaded, the user will not wait. As mentioned above, if the user crashes when blocking, even if it restarts, the response will be lost, so it must be re-called. The common way to solve this problem is that the user is asynchronous call service. In this way, the user can use a thread to send a request, and use another thread to receive a response. In this way, the user does not have to block to wait for a response, and other work can be performed simultaneously. Therefore, the user is not sensitive to spending more than a long time.

Broker supporting users asynchronous calling Web services is implemented by message delivery systems, the message delivery system uses a message queue to send requests and reception responses. Like the synchronization message agent, this pair of message queues act as a single address used to call the service, regardless of the number of providers may be listening, as shown in Figure 5.

Figure 5: Asynchronous Enterprise Service Bus

This method uses request-response mode to call Web services. Unlike HTTP specified in WS-I BP 1.1, the message queue is now executed. SOAP requests and responses are the same as WS-I BP, but they are now included in the message system.

Figure 6 shows how users use the Broker asynchronous call service, the specific steps are as follows:

The user sends SOAP requests in the form of a message in the request queue. Now, the user's work has been completed, you can use this thread to perform other work. Each provider can see the user in the request queue, which makes them to compete for users. Message delivery system determines which provider can receive a message and make sure there is only one provider to receive a message. The specific mode of operation depends on the implementation of the message delivery system. The winning provider receives messages from the request queue. The provider performs services. This provider sends SOAP responses in the form of messages in the response queue. Now, the provider's work has been completed, and other works can be performed using their threads (for example, another request). The user's listener thread receives messages that contain SOAP responses.

Figure 6: Asynchronous agent service call

Note that the selection of the provider is now packaged in the message delivery system to simplify the user's work. It should also be noted that if the user crashes after the request is issued, the message delivery system will save the response in the response queue even if the response is returned during this period.

At the same time, it is important to note that users do not use UDDI to find queues and response queues. Currently, there is no standard service for returning queue address pairs, so users must know these addresses exactly. Users either hard coding with these addresses or read them from an external configuration file. In the future, you need to extend UDDI or specify a similar service for users to find queries to call a specific service.

Now, you understand the connection mode of the service call. Next, let's take a look at other integration functions that can also be useful, then show you how to develop an ESB to provide these features.

Other integrated functions

With ESB, you can also exceed the service call and use other technical integration applications and SOA. Service calls are almost always two-way operations, which means that the request is sent from the user to the provider, and the response is returned in the opposite direction. Other integrated techniques are operated in one-way operation, wherein the sender transmits information to the recipient without waiting for a response; the recipient is only using information without responding.

data transmission

Sometimes the application simply transmits the data to another application without having to call the recipient's process and will definitely not wait. This is a typical integration problem: an application has data, while another application requires data. The sender does not need to tell the recipient how to handle the data; it simply needs to be available. You can transfer data through service calls, which is equivalent to calling the setter method, but the data is transferred to the RPC model. Data transfer is actually more similar to file transfer: data is exported from the sender and imports the recipient, and does not require the sender to disclose how the recipient processes data. This is more similar to the document style SOAP message instead of the RPC style message.

Data transfer with ESB can find the recipient and reliably transmit data. The sender does not have to know how to find the recipient, it only needs to know how to find ESB and trust the ESB will find the receiver. ESB is also responsible for reliably transmitting data. The sender only needs to transfer the data to the ESB and know that the data will be passed.

For more information on data transmission technology, see the Document Message mode. (For more information on this, see the Enterprise Integration Patterns listed in the reference.)

Event notification

Sometimes, you need to notify other applications that will be notified in an application. For example, if the user edits its address in an application, other applications should be notified and their own database so that they can update their records.

In addition, an application can invoke another application to notify its changes, but this method has three problems. Both problems are the same as data transfer. First, the service call should handle the information to the receiver knows too specifically. Second, it is often two-way, which makes the sender must wait (or even waiting) it is not a truly answer.

One of the third is also the most important thing by calling services. One is a problem. The service call is essentially one-on-one, that is, the user's pair provider, and the event notification is essentially a couple, need Broadcast to all related providers. Using service calls, the sender must track all related recipients and each of them is called. This notification broadcast preferably leaves the Broker between the sender and the receiver.

The message delivery with ESB can track the relevant recipient and ensure that the notification is passed to each recipient. In this way, the sender only needs to issue a notification to ensure that the notification is passed to all related recipients, regardless of who these recipients are. Since this operation is one-way, the sender can do other work at the same time when the notification is passed, and it can be passed concurrent notification.

For more information on data transmission technology, see the Event Message mode. (Part of Enterprise Integration Patterns listed in the reference).)

Development Enterprise Service Bus

Now you know the difference between the Web services in the direct call provider and the use of Broker. You also learned how Broker calls services in sync or asynchronously.

Such Broker is often referred to as ESB. So, what is the characteristics of ESB compared to the design and models that have been accepted?

Self-description and discovery

The Web service is different from the previous integration method that the user can dynamically bind to the service provider. The reason why it can do this is because of the following two main functions:

Self-describing --Web services can be described by machine readable manner. Two or more providers of the same service can be immediately identified even if they have a completely different implementation, as their declarative interfaces meet the same description. It can be found that --Web service providers can organize them to machine executable directories. Users can search for such a directory to find the provider of the required service. These self-description and self-production are completely different from previous integrated methods. Using another method, the interface will be executed at the time of compile, and the user will be bound to the provider. The message format is not expressed in a declared manner, but implies in both parties, and is not executable before the receiver successfully parsed the structure created by the sender.

The self-description service simplifies integration through the interface that can be performed. Dynamic Discovery Services makes no need to bind users to a specific provider at a particular address, but it has also brought some problems when running. The user should discover the provider of the service at one time or repeatedly discover the provider of the service?

It is very difficult to compile the user to the provider with a time to work when it is time to find a new provider. ESB provides a third option that is committed to supporting the user while binding to the service agent dynamically, while still capable of using multiple providers and choosing a new provider.

Therefore, ESB not only allows the service to be used so that the user can call them, but also provides the user to find the functionality of the service in programming.

Service gateway

The foundation of synchronous ESB is called a service gateway, which acts as an intermediary between service users and providers to promote synchronous proxy calls. Through the service gateway, you can access all well-known services and agents for each service. In this way, the gateway can provide one-stop service for any service of any provider who wants to call the gateway agent.

If the service coordinated service is a web service, these services are described. Each service uses WSDL to declare its interface, WSDL consists of four parts:

Port Type - The operation set of WEB service execution. The port type may be a port / operation (such as getQuote) stockBrokerServices. Message-request and response format, such as getQuoteRequest (including stock code) and getQuoteResponse (including price). Type -Web service uses data types, such as codes and prices (or just XS: String and XS: Decimal). Binding - the address of the call operation, such as http://stockbroker.example.com/getquote.

Such a gateway service - or more specifically, its service agent - is also possible. As mentioned earlier, the gateway provides this function in the form of a UDDI service. To find the address of the call service, the user can query the UDDI service of the gateway to find the provider of the required WSDL operation and retrieve the binding of the gateway agent of the operation.

Message bus

The basis of asynchronous enterprise service bus is a mode that has been accepted by everyone, called a message bus, such as the Enterprise Integration Patterns listed in the reference. The message bus is a collection of message channel (also known as queue or subject), which is typically configured to request-answer channel pair. Each pair represents the service that the user can call through the bus. The call party will request a message in the service request queue, then (asynchronously) listening to the results in the response queue. (The caller knows which results are correct for a specific request because it has the correct associated identifier.)

The user who calls the service actually does not know who is providing services. Service providers are also connected to the message bus and listen to the request message. If there are multiple service providers, they will actually compete with each other to become a service provider of the user who issues a specific request. Implementing the messaging system of the message bus acts as a message scheduler, and distributes the request message to the service provider. In some way, this distribution will be optimized in some way according to the load balancing, network delay, and the like. After the service provider receives the request, it executes the service, and then puts the result in the message in the consequent advice channel. In this way, providers and users never know directly from each other's address; they only know that the message bus and how to find the address of the appropriate channel, and they can communicate with the same channel. The message bus is the foundation of the ESB and is not a new thing. Application integration has used message queue products (such as WebSphere® MQ and Tibco Enterprise Message Service) to do this for more than ten years. In fact, people often say that if you are using enterprise messaging products, you have ESB. IBM customers have used WebSphere Business Integration Message Broker and WebSphere MQ for a long time.

So, is the ESB is the message bus? No, the message bus is definitely the foundation of asynchronous ESB, but the complete ESB also includes other functions. The ESB has a function of the message bus: that is, the above description and discovery functions.

Better message bus

So, if the message bus is not a complete ESB, what else can ESB do?

The shortcomings of the traditional messaging bus method are not described herein. From the user's point of view, there are many services, there are many channels for calling the service. But which channel is the appropriate channel used to call the service required by the user? Users cannot place requests in a request channel, which must know the appropriate channels for calling the specific services they need. Otherwise, it may eventually be violent, clearly needed a book, but finally bought is a plane ticket. In addition, even if the user (in some way) knows which channel to use (and which channel to get a response to get a response), what format should be used to know the data in the request (and what data need to be used format).

As mentioned above, WSDL solves this problem for synchronous web services, and temporarily describing standard selection of asynchronous services. What services are provided with the WSDL description channel related to the request channel, as well as the format of the request message that the user must provide. WSDL may also specify a call to listen to a response channel to get a response, and the format must have a response message. In this way, the calling application can be programmatically view channel pairs for calling services in programming, and know that they provide the required services in the request and response message format.

The self-describing the service channel has brought another problem, that is, which synchronization web services are discovered through UDDI. As described above, the user requests the address of the web service provider to the UDDI server, and the server responds to the provider's URL. The user then uses the URL to call the service.

ESB requires a similar directory service, a service with an API similar to UDDI, and the user can call such a service to request the address of the service required for WSDL operations. The ESB responds to the response channel in the appropriate request. So the ESB user (such as UDDI users) just know the following:

Describe the address of the Directory service of the WSDL ESB that needs to be called (it may be derived from the root address of the ESB) to the request for the service and the answer channel and start calling service, which is enough. In addition, this directory service is another service provided by the ESB to find the primary services for other services.

Is synchronization or asynchronous?

Service users need to make a choice between communication methods: Synchronization or asynchronous? In order to solve this problem, many ESBs will simultaneously support synchronous and asynchronous services, and in fact provide two call models for the same service. In this case, when the user requests the service address, it can get two matching addresses: one for synchronization, one for asynchronous. The user can then select its favorite call model. Regardless of the way it is used, the services implemented are the same, but the specific service provider instance may vary.

So ESB is better than traditional messaging bus, because it also makes services can be described, and provides directory services for finding other services. This is exactly to build ESB product suppliers.

Conclude

It can be seen that the service can be called by one of the following three ways:

Synchronize directly through Broker asynchronous through Broker

The enterprise service bus is Broker that supports synchronous and asynchronous calls. It also supports data transfer and event notifications between applications. It helps users find details between providers and process providers.

Synchronous ESB is a service gateway that acts as an intermediate coordinator of various services. Asynchronous ESB is a message bus that its service also supports self-description and discovery of web service functions. There is currently standard and modes for implementing synchronous ESB and message bus (simplified asynchronous ESB). Asynchronous ESB also requires other standards to give full play to their potential.

Reference

Learn

转载请注明原文地址:https://www.9cbs.com/read-130952.html

New Post(0)