Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Is there a function in the broker to "delete" a topic
  • From: Andrew Thomas <andrew.thomas@xxxxxxxxxxx>
  • Date: Fri, 26 Apr 2024 20:54:55 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=skkynet.com; dmarc=pass action=none header.from=skkynet.com; dkim=pass header.d=skkynet.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cj9nIrEDPJxSxMbz8Di24W5K3aU3zteqcQyK/1xAXQk=; b=EltTEDE91WmiogYyiAzUW7kjKfPTUw4ggjLa2x668PRHHAcmc8WDNU9dKmOrzQoV0xzW9kGZoA27y10rpMbdpNUTCvw5xN/jjAXKXC3pZOwC3rYkXqLaQ4GEIT1QJRRKqfgxiMkm7aZwSStn8ySpu2OQz4DXwSI5ZyvOPIj5yVPK0fSFNFTlP1Wid7v+GQ/YUMOcDf/G+DVgXL2RgmkvKsiBjbYc5Bf3J7aAuHKiWx7CwAhKLe0AW3wXOH+tng+hXB3n0oZfzGyiXs4e0Ttovi/ab/pGhGDMferKu1Qloyo6Vb6FQO8I4Vdu5YDbFE6wXM16gVjDlNGSq/F0+a9C7Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gz6ZViIJ4pwweA8D+JN6cpZRPCLKdRLiRmnG/lhoWIMiK1Lx6IlCwMvFrqmue4m9i3m7BhAJNTv0o0ZUBbCI52lm1D9tsq1MjkUSt2RaRGePhCKf7ruKAM7JHSBJSNpoHqP7BEQUKC9RDgUczzyK2HeAJiJL1QpMwXXkEy7JIlEkKMeLGIbqOIkQQoFdjhAcOhs2hpSpscMseYfe9Zh5P4gU+A8ZzgZ2BMVpl1VdplfAarFocQk/fxMq6blZgq0Np/fMAyE8E35qsUa8uC90H4aidv1wPNqCizdATOQMrwMjhtxI7fsGuJ/LTUTvGlqrtq23L4B9XhkLk0pTsrGsFA==
  • Delivered-to: mosquitto-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/mosquitto-dev/>
  • List-help: <mailto:mosquitto-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/mosquitto-dev>, <mailto:mosquitto-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/mosquitto-dev>, <mailto:mosquitto-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AdqHR66S0gVUSyKzTlOo+ZkiZpn7tAAYGvyABBjd2PA=
  • Thread-topic: [mosquitto-dev] Is there a function in the broker to "delete" a topic

Hi Roger,

Apologies for the delay in responding.  All my mosquitto messages were being filtered into a folder I never look at.

I eventually solved this by creating a new function:

int retain__clear_retained_message(char* topic)
{
	int rc = 0;
	char* local_sub;
	char** split_topics;
	struct mosquitto_msg_store stored;

	assert(topic);

	rc = sub__topic_tokenise(topic, &local_sub, &split_topics, NULL);
	if (rc) return rc;

	// If stored.payloadlen is 0, retain__store will remove the retained message
	memset(&stored, 0, sizeof(struct mosquitto_msg_store));
	set_retained(topic, &stored, split_topics);

	mosquitto__free(local_sub);
	mosquitto__free(split_topics);

	return 0;
}

Regards,
	Andrew


-----Original Message-----
From: mosquitto-dev <mosquitto-dev-bounces@xxxxxxxxxxx> On Behalf Of Roger Light via mosquitto-dev
Sent: Friday, April 5, 2024 6:25 PM
To: General development discussions for the mosquitto project <mosquitto-dev@xxxxxxxxxxx>
Cc: Roger Light <roger@xxxxxxxxxx>
Subject: Re: [mosquitto-dev] Is there a function in the broker to "delete" a topic

Hi Andrew,

There's not a straightforward way to do this in the broker. You could do what Nick suggested, then have a plugin deny access to outgoing messages with zero length, if your clients can't cope with zero length messages.

Regards,

Roger

On Fri, 5 Apr 2024 at 12:12, Andrew Thomas via mosquitto-dev <mosquitto-dev@xxxxxxxxxxx> wrote:
>
> Hello all,
>
>
>
> I am customizing the mosquitto broker, and I would like to be able to “delete” a topic.  As I understand it, that really just means removing retained messages for that topic.  I realize that the topic will re-appear if a client sends a new message to it, but this would still be very useful for my application.
>
>
>
> Are there functions in the broker code that:
>
> Remove the retained message for a topic, and Remove the retained 
> messages for a topic and all its descendants?
>
>
>
> Thanks,
>
>                 Andrew
>
>
>
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit 
> https://www.eclipse.org/mailman/listinfo/mosquitto-dev
_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/mosquitto-dev

Back to the top