Ask Cách tạo mã thông báo LBRTY

Primeamazon123

New member
### Cách tạo mã thông báo tự do

* [Liên kết đến bài viết tham khảo] (https://www.ibm.com/support/knowled...websphere.liberty.doc/product/lgwu030055.html)

1. ** Tạo một kênh thông báo. **

Một kênh thông báo là một điểm đến nơi Liberty có thể gửi thông báo.Để tạo kênh thông báo, hãy sử dụng lệnh sau:

`` `
Tạo thông báo-channel--name <-name> --Type <kiểu kênh>
`` `

Ví dụ: để tạo kênh thông báo JMS có tên là `My-JMS-Channel`, bạn sẽ sử dụng lệnh sau:

`` `
Tạo kênh thông báo-tên tôi-JMS-Channel --Type JMS
`` `

2. ** Định cấu hình kênh thông báo. **

Khi bạn đã tạo một kênh thông báo, bạn cần cấu hình nó.Để định cấu hình kênh thông báo, hãy sử dụng lệnh sau:

`` `
Định cấu hình thông báo-channel-tên <tên kênh> --Property <name> = <value>
`` `

Ví dụ: để định cấu hình kênh thông báo JMS để sử dụng hàng đợi `my-cater`, bạn sẽ sử dụng lệnh sau:

`` `
Định cấu hình kênh thông báo-tên của tôi-JMS-Channel-Chuỗi hàng đợi = My-Queue
`` `

3. ** Tạo trình nghe thông báo. **

Người nghe thông báo là một lớp mà Liberty gọi khi nhận được thông báo.Để tạo trình nghe thông báo, hãy tạo một lớp thực hiện `com.ibm.websphere.notification.listener.notificationListener` giao diện.

Giao diện `Thông báoListener` có hai phương thức:

* `Onnotification (Thông báo thông báo)`: Phương thức này được gọi khi nhận được thông báo.
* `OneXception (Ngoại lệ ngoại lệ)`: Phương thức này được gọi nếu xảy ra lỗi trong khi xử lý thông báo.

4. ** Đăng ký trình nghe thông báo. **

Khi bạn đã tạo một người nghe thông báo, bạn cần đăng ký nó với Liberty.Để đăng ký trình nghe thông báo, hãy sử dụng lệnh sau:

`` `
Đăng ký thông báo-Listener-Lớp <Classer-Class>
`` `

Ví dụ: để đăng ký trình nghe thông báo mà bạn đã tạo ở bước trước, bạn sẽ sử dụng lệnh sau:

`` `
Đăng ký thông báo-Listener-com.example.mynotificationListener
`` `

5. ** Gửi một thông báo. **

Để gửi thông báo, sử dụng lệnh sau:

`` `
Gửi thông báo --Channel <tên kênh>
`` `

Ví dụ: để gửi thông báo đến kênh thông báo JMS mà bạn đã tạo trong các bước trước, bạn sẽ sử dụng lệnh sau:

`` `
Gửi thông báo-Hàngannel My-JMS-Channel--Message "Hello World!"
`` `

### hashtags

* #Liberty
* #notifications
* #Jmx
* #JMS
* #Java
=======================================
### How to create Liberty notification code

* [Link to reference article](https://www.ibm.com/support/knowledgecenter/en/SSQNUZ_9.0.0/com.ibm.websphere.liberty.doc/product/lgwu030055.html)

1. **Create a notification channel.**

A notification channel is a destination where Liberty can send notifications. To create a notification channel, use the following command:

```
create notification-channel --name <channel-name> --type <channel-type>
```

For example, to create a JMS notification channel named `my-jms-channel`, you would use the following command:

```
create notification-channel --name my-jms-channel --type jms
```

2. **Configure the notification channel.**

Once you have created a notification channel, you need to configure it. To configure a notification channel, use the following command:

```
configure notification-channel --name <channel-name> --property <name>=<value>
```

For example, to configure the JMS notification channel to use the queue `my-queue`, you would use the following command:

```
configure notification-channel --name my-jms-channel --property queue=my-queue
```

3. **Create a notification listener.**

A notification listener is a class that Liberty calls when a notification is received. To create a notification listener, create a class that implements the `com.ibm.websphere.notification.listener.NotificationListener` interface.

The `NotificationListener` interface has two methods:

* `onNotification(Notification notification)`: This method is called when a notification is received.
* `onException(Exception exception)`: This method is called if an error occurs while processing a notification.

4. **Register the notification listener.**

Once you have created a notification listener, you need to register it with Liberty. To register a notification listener, use the following command:

```
register notification-listener --class <listener-class>
```

For example, to register the notification listener that you created in the previous step, you would use the following command:

```
register notification-listener --class com.example.MyNotificationListener
```

5. **Send a notification.**

To send a notification, use the following command:

```
send notification --channel <channel-name> --message <message>
```

For example, to send a notification to the JMS notification channel that you created in the previous steps, you would use the following command:

```
send notification --channel my-jms-channel --message "Hello world!"
```

### Hashtags

* #Liberty
* #notifications
* #Jmx
* #JMS
* #Java
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock