Messaging Essentials messaging-essentials
This page documents the details of working with using the Messaging component to include a messaging feature on a website.
Essentials for Client-Side essentials-for-client-side
Compose Message
Message List (for Inbox, Sent, and Trash)
See also Client-side Customizations
Essentials for Server-Side essentials-for-server-side
-
for SCF components
-
for the service
setInboxPath
()setSentItemsPath
()
code language-none |
---|
|
Community Site community-site
A community site structure, created using the wizard, will include the messaging feature when selected. See User Management
settings of Community Sites Console.
Sample Code: Message Received Notification sample-code-message-received-notification
The Social Messaging feature throw events for operations, for example send
, marking read
, marking delete
. These events can be caught and actions taken on the data contained in the event.
The following example is of an event handler which listens for the message sent
event and sends an email to all message recipients using the Day CQ Mail Service
.
To try the server-side sample script, you will need a development environment and the ability to build an OSGi bundle.
-
Login as an administrator to
[CRXDE|Lite](http://localhost:4502/crx/de)
-
Create a
bundle node
in/apps/engage/install
with arbitrary names, such as- Symbolic Name: com.engage.media.social.messaging.MessagingNotification
- Name: Getting Started Tutorial Message Notificaton
- Description: a sample service for sending an email notification to users when they receive a message
- Package:
com.engage.media.social.messaging.notification
-
Navigate to
/apps/engage/install/com.engage.media.social.messaging.MessagingNotification/src/main/java/com/engage/media/social/messaging/notification
- Delete the
Activator.java
class automatically created - Create class
MessageEventHandler.java
- Copy/paste the code below into
MessageEventHandler.java
- Delete the
-
Click Save All
-
Navigate to
/apps/engage/install/com.engage.media.social.messaging.MessagingNotification/com.engage.media.social.messaging.MessagingNotification.bnd
and add all the import statements as written in theMessageEventHandler.java
code. -
Build the bundle
-
Ensure
Day CQ Mail Service
OSGi service is configured -
Login as one demo user and send email to another
-
The recipient should receive an email regarding a new message
MessageEventHandler.java messageeventhandler-java
package com.engage.media.social.messaging.notification;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Reference;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache